创建表
1.可以用Navicat创建
2.使用SQL语句
create table new_customers(cust_id int,cust_name char(50),cust_address(50)
表创建的基础
create table new_customers(cust_id int primary key,cust_name char(50),cust_address(50)
使用null值
create table new_customers(cust_id int not null,cust_name char(50),cust_address(50)
主键再介绍
create table new_customers(cust_id int primary key,cust_name char(50),cust_address(50)
使用auto_increment
create table new_customers(cust_id int primary key auto_increment,cust_name char(50),cust_address(50)
指定默认值
create table new_customers(cust_id int primary key,cust_name char(50),cust_address(50) default 'zhuahai'
引擎类型
create table new_customers(cust_id int primary key,cust_name char(50),cust_address(50) engine=innodb;
注意:外键不能跨引擎
修改表
alter table new_customers add cust_country varchar(50);
alter table new_customers drop cust_country varchar(50);
alter table orders add constrain FK_orders foreign key(cust_ic) refernces customers(cust_ic);
删除表
drop table new_cutomers;
重命名表
rename table oreders to new_oreders;