MySQL Import csv file content to Table

 EDITORIAL

The test object is introduced into a csv file contents to the table, at the same time recording increment primary key settings.

Test uses MySQL5.5.

Customer_info following new table, the primary key is not provided.

Modifying the table, add a primary key id, and set increment.

ALTER TABLE customer_info ADD COLUMN id INT AUTO_INCREMENT NOT NULL PRIMARY KEY;

Import steps

1. In order to simulate data, these three records directly exported to csv file.

 

2. customer_info import the file into the table.

 

 

 

 

 

 

3. Verify the import results

Refresh table, view the import results from the first seating is really beginning to import.

summary

MySQL new auto-increment primary keys

ALTER TABLE customer_info ADD COLUMN id INT AUTO_INCREMENT NOT NULL PRIMARY KEY;

MySQL modify the primary key field is incremented

ALTER TABLE customer_info CHANGE COLUMN id id INT AUTO_INCREMENT PRIMARY KEY;

If the id itself is the primary key, just want to increment above sql do not need to add a PRIMARY KEY.

SQLServer new auto-increment primary keys

ALTER TABLE sms_rec ADD id INT IDENTITY (1, 1) PRIMARY KEY;

修改字段为自增主键就不表演了..因为我是先把id那列干掉然后执行的上面一行...low了点, 能用...

 

Guess you like

Origin www.cnblogs.com/yadongliang/p/11305502.html