create table mydb(
id in auto_increment primary key not null,
price varchar(10),
title varchar(100),
detail varchar(500),
url varchar(50),
seller_id varchar(50);
LOAD DATA LOCAL INFILE 'C:\\Users\\Administrator\\Desktop\\MacDB.dat'
INTO TABLE macdb #表名
FIELDS TERMINATED BY '::'
LINES TERMINATED BY '\n'
(id,price,title,detail,url,seller_id);
外键
select hat_city.city,hat_province.province
from hat_province
inner join hat_city on hat_province.provinceID=hat_city.cityID;
--删除外键
语法:alter table 表名 drop constraint 外键约束名
如:
alter table Stu_PkFk_Sc drop constraint FK_s
alter table Stu_PkFk_SC drop constraint FK_c
--添加外键
语法:alter table 表名 add constraint 外键约束名 foreign key(列名) references 引用外键表(列名)
如:
alter table Stu_PkFk_Sc
add constraint Fk_s
foreign key (sno)
references Stu_PkFk_S(sno)
go
--删除主键
语法:alter table 表名 drop constraint 主键约束名
如:
alter table Stu_PkFk_S drop constraint PK_S
go
--增加主键
语法:alter 表名 add constraint 主键约束名 primary key(列名)
alter table Stu_PkFk_S add constraint PK_S primary key (sno)
go