简体   繁体   English

一次添加新列后如何在表中插入值?

[英]How to insert values in table after adding new column at once?

I have a mysql table. 我有一个mysql表。 I have inserted a new column namely s_no (integer) at first position. 我在第一个位置插入了一个新列,即s_no(整数)。 Now I want to insert values from 1, 2, 3 at once and also want to make it primary key. 现在,我想一次插入1、2、3中的值,还希望使其成为主键。

To make it primary key: 使其成为主键:

ALTER TABLE tableName
  ADD PRIMARY KEY (s_no);

Read more at: 阅读更多信息:

http://www.mysqltutorial.org/mysql-primary-key/ http://www.mysqltutorial.org/mysql-primary-key/

To insert rows: 要插入行:

INSERT INTO tableName
    (a,b,c)
VALUES
    (1,2,3),
    (4,5,6),
    (7,8,9);  

INSERT statements that use VALUES syntax can insert multiple rows. 使用VALUES语法的INSERT语句可以插入多行。 To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. 为此,请包括多个列值列表,每个列值括在括号内并用逗号分隔。

Read more at: 阅读更多信息:

http://dev.mysql.com/doc/refman/5.5/en/insert.html http://dev.mysql.com/doc/refman/5.5/en/insert.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM