mysql创建表以及相关内容

-----建表----

create   table  student       

(id int  primary key,

name char(6) not null,

sex char(2),

age smallint

);

 

-----修改表---

(1)添加新列

Alter table student

add  email varchar(20) null;

如果向表中添加多个列:

Alter table student

add  email varchar(20) null,

add  phone varchr(12) not null;

 

(2) 修改表中的列

1 列名的修改

Exec sp_rename 'student.email', 'new_emal', 'column';

 

alter table student

alter column <列名> <新数据类型>;修改数据类型

drop column <列名> ; 删除列名

 

----修改表名---

rename  table  student to newstudent;

------删除表-----

Drop table student;


------当我们了解了数据库之后我们发现一种数据库可以有多重存储引擎,比如mysql就支持很多存储引擎,常用的有innodb ,myisam等,当我们选择不同的存储引擎时这个建立的表在存储方式,索引速度以及对事物的支持程度不同,所以存储引擎也叫做表类型。在建表的时候我们可以选择存储引擎。

 create table  tablename (id int , age int, score float)  engine="innodb"; 这里建立了一个存储引擎为innodb的表;--------

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值