Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 | 

INSERT Using Queries


Using a query in an INSERT statement, you can create multiple data with a single INSERT statement.

If you want to extract data from another table based on a specific search condition, use a query to include all the data that satisfies the condition in the table specified in the INSERT statement.


INSERT INTO table_name [ (attribute_list ) ] query_statement [ ; ]

  • table_name : Specifies the name of the table where the data is to be inserted.
  • attribute_list : Specifies the column names for the data to be inserted. The data type defined here must be the same as that of the result of the query_statement.
  • query_statement : Defines a query to extract the data to be inserted.

The following is an example of creating a table named man and then inserting the result of the query that retrieves the names of male athletes from the athlete table. You can see that 4087 rows are inserted by a single INSERT statement.

name VARCHAR(40)

csql> INSERT INTO man (name) SELECT name FROM athlete WHERE gender ='M';
csql> ;x
4087 rows inserted.
Current transaction has been committed.
1 command(s) successfully processed.