Insert is writing data to the table, each INSERT statement can write one piece of data, or it can write multiple data. You can also use additional query result sets in insert to write query results to a table.
Test table
Test=createtableintvarchar(+)); CREATE TABLE
Example 1. Single Record insert
Test=insert intovalues (1,'test'); INSERT 0 1
Example 2. Multiple record inserts
The difference between an insert and a single record is that each value is separated by a comma, and the last value is followed by a semicolon.
Test=insertinto Values (2,'test'), (3 ,'sd'), (4,'ff'); INSERT 0 3
Example 3. Query Results Insert
Generate_series (1,10) generates 1 to 10 consecutive 10 numbers, concat parameters are strung together to form a new string, and the arguments can be many.
Test=#Insert intoTbl_insert (A, B)SelectId,concat (ID,'Test') fromGenerate_series (1,Ten) ID;INSERT 0 TenTest=#Select * fromTbl_insert; a|b----+-------- 1 |Test2 |Test3 |SD4 |FF1 |1test2 |2test3 |3test4 |4test5 |5test6 |6test7 |7test8 |8test9 |9testTen |10test ( -Rows
Example 4. SELECT into creates a new table and writes the query results to the table, but fails if the table already exists.
Test=Select* into Tbl_insert1 from tbl_insert; SELECT - Test = Select * into Tbl_insert1 from Tbl_insert; ERROR: exists
PostgreSQL----INSERT