insertinto语句的写法
时间:2024-08-23
INSERT INTO 语句用于向数据库表中插入数据。常见的三种写法如下:
插入单条记录:
sql
INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3);
插入多条记录:
sql
INSERT INTO table_name (column1, column2, column3)
VALUES (value1a, value2a, value3a),
(value1b, value2b, value3b),
(value1c, value2c, value3c);
从另一表插入数据:
sql
INSERT INTO table_name (column1, column2, column3)
SELECT column1, column2, column3
FROM another_table
WHERE condition;