mysql 使用 insert 語句向表中插入數(shù)據(jù)。其語法為:insert into ( , … ) values ( , … )。參數(shù)包括::要插入數(shù)據(jù)的表名;:要插入數(shù)據(jù)的列名;:要插入列中的值。例如,將一行數(shù)據(jù)插入名為 employees 的表中:insert into employees (id, name, email) values (1, ‘john doe
MySQL 添加數(shù)據(jù)語句
MySQL 中用于向表中插入數(shù)據(jù)的語句是 INSERT 語句。
語法:
<code class="sql">INSERT INTO ( , ... ) VALUES ( , ... );</code>
登錄后復(fù)制
參數(shù):
: 要向其插入數(shù)據(jù)的表的名稱。
: 要插入數(shù)據(jù)的列的名稱,可以是單個(gè)列或多個(gè)列。
: 要插入列中的值,可以是單個(gè)值或多個(gè)值。
使用示例:
假設(shè)我們有一個(gè)名為 employees 的表,其中包含 id、name 和 email 三列。以下語句將向表中插入一行數(shù)據(jù):
<code class="sql">INSERT INTO employees (id, name, email) VALUES (1, 'John Doe', '[email protected]');</code>
登錄后復(fù)制
注意事項(xiàng):
插入的值的順序必須與 中列的順序一致。
如果未指定 ,則值將插入表中的所有列。
如果要插入 NULL 值,需要在值中指定 NULL。
可以使用 VALUES() 子句多次插入行,如下所示:
<code class="sql">INSERT INTO employees (id, name, email) VALUES (2, 'Jane Doe', '[email protected]'), (3, 'John Smith', '[email protected]');</code>
登錄后復(fù)制






