Skip to content

Commit 488d9b5

Browse files
committed
Update INSERT command examples in both CN and EN versions
- Add new table 'new_products' to demonstrate more complex INSERT examples - Include INSERT commands for the new table with sample data - Update the example of inserting query results to use a specific date
1 parent 268d95d commit 488d9b5

File tree

2 files changed

+26
-2
lines changed
  • CN/modules/ROOT/pages/v4.4
  • EN/modules/ROOT/pages/v4.4

2 files changed

+26
-2
lines changed

CN/modules/ROOT/pages/v4.4/8.adoc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ CREATE TABLE products (
149149
name text,
150150
price numeric
151151
);
152+
153+
CREATE TABLE new_products (
154+
product_no int ,
155+
name varchar(255),
156+
price DECIMAL(10, 2),
157+
release_date DATE
158+
);
152159
```
153160

154161
一个插入一行的命令将是:
@@ -191,14 +198,19 @@ INSERT INTO products (product_no, name, price) VALUES
191198
(1, 'Cheese', 9.99),
192199
(2, 'Bread', 1.99),
193200
(3, 'Milk', 2.99);
201+
202+
INSERT INTO new_products (product_no, name, price, release_date) VALUES
203+
(1, 'A', 100.00, '2025-05-29'),
204+
(2, 'B', 150.50, '2024-11-20'),
205+
(3, 'C', 200.75, '2025-05-29');
194206
```
195207

196208
也可以插入查询的结果(可能没有行、一行或多行):
197209

198210
```
199211
INSERT INTO products (product_no, name, price)
200212
SELECT product_no, name, price FROM new_products
201-
WHERE release_date = 'today';
213+
WHERE release_date = '2025-05-29';
202214
```
203215

204216
这提供了用于计算要插入的行的SQL查询机制( http://www.postgresql.org/docs/17/queries.html[第 7 章])的全部功能。

EN/modules/ROOT/pages/v4.4/8.adoc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ CREATE TABLE products (
155155
name text,
156156
price numeric
157157
);
158+
159+
CREATE TABLE new_products (
160+
product_no int ,
161+
name varchar(255),
162+
price DECIMAL(10, 2),
163+
release_date DATE
164+
);
158165
```
159166

160167
An example command to insert a row would be:
@@ -197,14 +204,19 @@ INSERT INTO products (product_no, name, price) VALUES
197204
(1, 'Cheese', 9.99),
198205
(2, 'Bread', 1.99),
199206
(3, 'Milk', 2.99);
207+
208+
INSERT INTO new_products (product_no, name, price, release_date) VALUES
209+
(1, 'A', 100.00, '2025-05-29'),
210+
(2, 'B', 150.50, '2024-11-20'),
211+
(3, 'C', 200.75, '2025-05-29');
200212
```
201213

202214
It is also possible to insert the result of a query (which might be no rows, one row, or many rows):
203215

204216
```
205217
INSERT INTO products (product_no, name, price)
206218
SELECT product_no, name, price FROM new_products
207-
WHERE release_date = 'today';
219+
WHERE release_date = '2025-05-29';
208220
```
209221

210222
This provides the full power of the SQL query mechanism for computing the rows to be inserted.

0 commit comments

Comments
 (0)