Versions available for this page: CUBRID 8.2.1 |
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 [ ; ]
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.
CREATE TABLE man (
csql> INSERT INTO man (name) SELECT name FROM athlete WHERE gender ='M';
4087 rows inserted.
Current transaction has been committed.
1 command(s) successfully processed.