0
点赞
收藏
分享

微信扫一扫

Mysql基础第二十四天,创建表和操纵表


创建表

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'

引擎类型

Mysql基础第二十四天,创建表和操纵表_外键


Mysql基础第二十四天,创建表和操纵表_外键_02

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;


举报

相关推荐

0 条评论