我有一个CSV文件,有所有信息,我将所有信息转换成一个表并存储在MySQL中。它有很多领域。创建这样的表的最佳方法是什么:如何设置表的自动递增主键,以及如何从源表中获取唯一名称。
您通常会创建一个带有auto_increated主键的表,然后使用select distinct
:进行馈送
create table disticts(
district_id int auto_increment primary key,
district_name varchar(100)
);
insert into disticts (district_name)
select distinct district_name from mytable