PostgreSQL 7.4.30 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Fast Forward | Next |
INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) | query }
INSERT allows one to insert new rows into a table. One can insert a single row at a time or several rows as a result of a query.
The columns in the target list may be listed in any order. Each column not present in the target list will be inserted using a default value, either its declared default value or null.
If the expression for each column is not of the correct data type, automatic type conversion will be attempted.
You must have INSERT privilege to a table in order to insert into it. If you use the query clause to insert rows from a query, you also need to have SELECT privilege on any table used in the query.
The name (optionally schema-qualified) of an existing table.
The name of a column in table.
All columns will be filled with their default values.
An expression or value to assign to column.
This column will be filled with its default value.
A query (SELECT statement) that supplies the rows to be inserted. Refer to the SELECT statement for a description of the syntax.
On successful completion, an INSERT command returns a command tag of the form
INSERT oid count
The count is the number of rows inserted. If count is exactly one, and the target table has OIDs, then oid is the OID assigned to the inserted row. Otherwise oid is zero.
Insert a single row into table films:
INSERT INTO films VALUES ('UA502', 'Bananas', 105, '2025-08-08', 'Comedy', '82 minutes');
In this second example, the last column len is omitted and therefore it will have the default value of null:
INSERT INTO films (code, title, did, date_prod, kind) VALUES ('T_601', 'Yojimbo', 106, '2025-08-08', 'Drama');
The third example uses the DEFAULT clause for the date columns rather than specifying a value:
INSERT INTO films VALUES ('UA502', 'Bananas', 105, DEFAULT, 'Comedy', '82 minutes'); INSERT INTO films (code, title, did, date_prod, kind) VALUES ('T_601', 'Yojimbo', 106, DEFAULT, 'Drama');
This examples inserts several rows into table films from table tmp:
INSERT INTO films SELECT * FROM tmp;
This example inserts into array columns:
-- Create an empty 3x3 gameboard for noughts-and-crosses -- (all of these commands create the same board) INSERT INTO tictactoe (game, board[1:3][1:3]) VALUES (1,'{{"","",""},{},{"",""}}'); INSERT INTO tictactoe (game, board[3][3]) VALUES (2,'{}'); INSERT INTO tictactoe (game, board) VALUES (3,'{{,,},{,,},{,,}}');
INSERT conforms fully to the SQL standard. Possible limitations of the query clause are documented under SELECT.
cdc是什么意思 | 忽悠什么意思 | 阴道炎是什么引起的 | 狐臭是什么人种的后代 | 气血虚吃什么 |
孕妇吃什么钙片 | 什么的去路 | 空调外机很响是什么原因 | 郭五行属什么 | 1940年中国发生了什么 |
晚上吃芒果有什么好处和坏处 | 梦见妈妈出轨预示什么意思 | 女s是什么 | 什么是节气 | 伟五行属什么 |
名落孙山是什么意思 | 女人胆固醇高什么原因 | 同位分是什么意思 | bml是什么意思 | 饮料喝多了有什么危害 |
摔伤用什么药好得快hcv8jop9ns0r.cn | 六九年属什么hcv9jop6ns1r.cn | 深井冰什么意思hcv8jop0ns5r.cn | 梦见买白菜是什么意思hcv9jop7ns3r.cn | 发烧咳嗽挂什么科hcv8jop9ns0r.cn |
梦见刺猬是什么意思hcv8jop5ns5r.cn | 颌下腺肿大是什么原因hcv8jop9ns0r.cn | 鹏字五行属什么creativexi.com | 高血糖能吃什么水果hcv7jop5ns3r.cn | 养老保险什么时候开始交hcv8jop5ns3r.cn |
抗角蛋白抗体阳性是什么意思hcv8jop2ns2r.cn | 石斛有什么作用hcv7jop6ns6r.cn | 巡视员是什么级别hcv7jop9ns0r.cn | 梦见双头蛇是什么征兆hcv8jop3ns4r.cn | 什么鸡蛋营养价值最高weuuu.com |
铜是什么颜色的hcv7jop6ns6r.cn | 营长是什么级别hcv9jop4ns9r.cn | 尿结石挂什么科hcv8jop8ns1r.cn | 酵素是什么hcv8jop7ns1r.cn | 闭角型青光眼是什么意思hcv8jop4ns5r.cn |