9/11/2023 0 Comments Postgresql insert into select fromVALUES( '', 'PostgreSQL Tutorial') Code language: SQL (Structured Query Language) ( sql ) The following statement inserts a new row into the links table: INSERT INTO links ( url, name) 1) PostgreSQL INSERT – Inserting a single row into a table In this tutorial, you just need to execute it to create a new table. Note that you will learn how to create a new table in the subsequent tutorial. ) Code language: SQL (Structured Query Language) ( sql ) The following statement creates a new table called linksfor the demonstration: DROP TABLE IF EXISTS links RETURNING output_expression AS output_name Code language: SQL (Structured Query Language) ( sql ) PostgreSQL INSERT statement examples For example: INSERT INTO table_name(column1, column2, …) To rename the returned value, you use the AS keyword followed by the name of the output. RETURNING id Code language: SQL (Structured Query Language) ( sql ) If you want to return just some information of the inserted row, you can specify one or more columns after the RETURNING clause.įor example, the following statement returns the id of the inserted row: INSERT INTO table_name(column1, column2, …) RETURNING * Code language: SQL (Structured Query Language) ( sql ) If you want to return the entire inserted row, you use an asterisk ( *) after the RETURNING keyword: INSERT INTO table_name(column1, column2, …) The INSERT statement also has an optional RETURNING clause that returns the information of the inserted row. The count is the number of rows that the INSERT statement inserted successfully. Typically, the INSERT statement returns OID with value 0. PostgreSQL used the OID internally as a primary key for its system tables. The INSERT statement returns a command tag with the following form: INSERT oid count The columns and values in the column and value lists must be in the same order.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |