Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjinj committed Aug 28, 2024
1 parent 335a0ba commit 35e2724
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 92 deletions.
94 changes: 48 additions & 46 deletions en/sql/query/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
UPDATE
******

You can update the column value of a record stored in the target table or view to a new one by using the **UPDATE** statement. Specify the name of the column to update and a new value in the **SET** clause, and specify the condition to be used to extract the record to be updated in the :ref:`where-clause`. You can one or more tables only with one **UPDATE** statement.
You can update the column value of a record stored in the target table or view to a new one by using the **UPDATE** statement.
Specify the name of the column to update and a new value in the **SET** clause, and specify the condition to be used to extract the record to be updated in the :ref:`where-clause`.
You can one or more tables only with one **UPDATE** statement.

::

Expand Down Expand Up @@ -55,53 +57,9 @@ The following is allowed only when a single table is specified in <*table_specif

From CUBRID 10.0 onward, updates to views containing **JOIN** clauses are possible.

.. _example_single_table_update:

.. rubric:: Example 1. Single Table Update

This example uses the *LIMIT 3* clause to update only up to 3 records with *name IS NULL*.

.. code-block:: sql
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int, name varchar, phone varchar);
INSERT INTO t1 VALUES (NULL, NULL, '000-0000');
INSERT INTO t1 VALUES ( 1, 'aaa', '111-1111');
INSERT INTO t1 VALUES ( 2, 'bbb', '222-2222');
INSERT INTO t1 VALUES ( 3, 'ccc', '333-3333');
INSERT INTO t1 VALUES ( 4, NULL, '000-0000');
INSERT INTO t1 VALUES ( 5, NULL, '000-0000');
INSERT INTO t1 VALUES ( 6, 'ddd', '000-0000');
INSERT INTO t1 VALUES ( 7, NULL, '777-7777');
SELECT * FROM t1 WHERE name IS NULL;
id name phone
=========================================================
NULL NULL '000-0000'
4 NULL '000-0000'
5 NULL '000-0000'
7 NULL '777-7777'
UPDATE t1 SET name='update', phone='999-9999' WHERE name IS NULL LIMIT 3;
SELECT * FROM t1;
id name phone
=========================================================
NULL 'update' '999-9999'
1 'aaa' '111-1111'
2 'bbb' '222-2222'
3 'ccc' '333-3333'
4 'update' '999-9999'
5 'update' '999-9999'
6 'ddd' '000-0000'
7 NULL '777-7777'
.. _example_single_table_update_using_order_by:

.. rubric:: Example 2. Single Table Update Using ORDER BY Clause
.. rubric:: Example 1. Single Table Update Using ORDER BY Clause

.. code-block:: sql
Expand Down Expand Up @@ -142,6 +100,50 @@ Using the :ref:`order-by-clause` can change the order in which records are updat
trigger2 executed
trigger2 executed
.. _example_single_table_update_using_limit:

.. rubric:: Example 2. Single Table Update Using LIMIT Clause

This example uses the *LIMIT 3* clause to update only up to 3 records with *name IS NULL*.

.. code-block:: sql
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int, name varchar, phone varchar);
INSERT INTO t1 VALUES (NULL, NULL, '000-0000');
INSERT INTO t1 VALUES ( 1, 'aaa', '111-1111');
INSERT INTO t1 VALUES ( 2, 'bbb', '222-2222');
INSERT INTO t1 VALUES ( 3, 'ccc', '333-3333');
INSERT INTO t1 VALUES ( 4, NULL, '000-0000');
INSERT INTO t1 VALUES ( 5, NULL, '000-0000');
INSERT INTO t1 VALUES ( 6, 'ddd', '000-0000');
INSERT INTO t1 VALUES ( 7, NULL, '777-7777');
SELECT * FROM t1 WHERE name IS NULL;
id name phone
=========================================================
NULL NULL '000-0000'
4 NULL '000-0000'
5 NULL '000-0000'
7 NULL '777-7777'
UPDATE t1 SET name='update', phone='999-9999' WHERE name IS NULL LIMIT 3;
SELECT * FROM t1;
id name phone
=========================================================
NULL 'update' '999-9999'
1 'aaa' '111-1111'
2 'bbb' '222-2222'
3 'ccc' '333-3333'
4 'update' '999-9999'
5 'update' '999-9999'
6 'ddd' '000-0000'
7 NULL '777-7777'
.. _example_update_with_joins:

.. rubric:: Example 3. Update Using Joins
Expand Down
94 changes: 48 additions & 46 deletions ko/sql/query/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
UPDATE
******

**UPDATE** 문을 사용하면 대상 테이블 또는 뷰에 저장된 레코드의 칼럼 값을 새로운 값으로 업데이트할 수 있다. **SET** 절에는 업데이트할 칼럼 이름과 새로운 값을 명시하며, :ref:`where-clause`\ 에는 업데이트할 레코드를 추출하기 위한 조건을 명시한다. 하나의 **UPDATE** 문으로 하나 이상의 테이블 또는 뷰를 업데이트할 수 있다.
**UPDATE** 문을 사용하면 대상 테이블 또는 뷰에 저장된 레코드의 칼럼 값을 새로운 값으로 업데이트할 수 있다.
**SET** 절에는 업데이트할 칼럼 이름과 새로운 값을 명시하며, :ref:`where-clause`\ 에는 업데이트할 레코드를 추출하기 위한 조건을 명시한다.
하나의 **UPDATE** 문으로 하나 이상의 테이블 또는 뷰를 업데이트할 수 있다.

::

Expand Down Expand Up @@ -56,53 +58,9 @@ UPDATE

CUBRID 10.0 버전부터는 **JOIN** 구문을 포함하는 뷰에 대한 업데이트가 가능하다.

.. _example_single_table_update:

.. rubric:: 예시 1. 단일 테이블 업데이트

이 예시는 *LIMIT 3* 절을 이용하여 *name IS NULL*\인 레코드 중 최대 3개만 업데이트한다.

.. code-block:: sql
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int, name varchar, phone varchar);
INSERT INTO t1 VALUES (NULL, NULL, '000-0000');
INSERT INTO t1 VALUES ( 1, 'aaa', '111-1111');
INSERT INTO t1 VALUES ( 2, 'bbb', '222-2222');
INSERT INTO t1 VALUES ( 3, 'ccc', '333-3333');
INSERT INTO t1 VALUES ( 4, NULL, '000-0000');
INSERT INTO t1 VALUES ( 5, NULL, '000-0000');
INSERT INTO t1 VALUES ( 6, 'ddd', '000-0000');
INSERT INTO t1 VALUES ( 7, NULL, '777-7777');
SELECT * FROM t1 WHERE name IS NULL;
id name phone
=========================================================
NULL NULL '000-0000'
4 NULL '000-0000'
5 NULL '000-0000'
7 NULL '777-7777'
UPDATE t1 SET name='update', phone='999-9999' WHERE name IS NULL LIMIT 3;
SELECT * FROM t1;
id name phone
=========================================================
NULL 'update' '999-9999'
1 'aaa' '111-1111'
2 'bbb' '222-2222'
3 'ccc' '333-3333'
4 'update' '999-9999'
5 'update' '999-9999'
6 'ddd' '000-0000'
7 NULL '777-7777'
.. _example_single_table_update_using_order_by:

.. rubric:: 예시 2. ORDER BY 절을 이용한 단일 테이블 업데이트
.. rubric:: 예시 1. ORDER BY 절을 이용한 단일 테이블 업데이트

.. code-block:: sql
Expand Down Expand Up @@ -143,6 +101,50 @@ UPDATE
trigger2 executed
trigger2 executed
.. _example_single_table_update_using_limit:

.. rubric:: 예시 2. LIMIT 절을 활용한 단일 테이블 업데이트

이 예시는 *LIMIT 3* 절을 이용하여 *name IS NULL*\인 레코드 중 최대 3개만 업데이트한다.

.. code-block:: sql
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int, name varchar, phone varchar);
INSERT INTO t1 VALUES (NULL, NULL, '000-0000');
INSERT INTO t1 VALUES ( 1, 'aaa', '111-1111');
INSERT INTO t1 VALUES ( 2, 'bbb', '222-2222');
INSERT INTO t1 VALUES ( 3, 'ccc', '333-3333');
INSERT INTO t1 VALUES ( 4, NULL, '000-0000');
INSERT INTO t1 VALUES ( 5, NULL, '000-0000');
INSERT INTO t1 VALUES ( 6, 'ddd', '000-0000');
INSERT INTO t1 VALUES ( 7, NULL, '777-7777');
SELECT * FROM t1 WHERE name IS NULL;
id name phone
=========================================================
NULL NULL '000-0000'
4 NULL '000-0000'
5 NULL '000-0000'
7 NULL '777-7777'
UPDATE t1 SET name='update', phone='999-9999' WHERE name IS NULL LIMIT 3;
SELECT * FROM t1;
id name phone
=========================================================
NULL 'update' '999-9999'
1 'aaa' '111-1111'
2 'bbb' '222-2222'
3 'ccc' '333-3333'
4 'update' '999-9999'
5 'update' '999-9999'
6 'ddd' '000-0000'
7 NULL '777-7777'
.. _example_update_with_joins:

.. rubric:: 예시 3. 조인을 활용한 업데이트
Expand Down

0 comments on commit 35e2724

Please sign in to comment.