mysql数据表命令是_MySQL_数据表命令

数据表操作

关于Mysql的数据类型,点击一下

1.创建数据表:

create [temporapy] table [if not exists]

[( [完整性约束条件] [,...])]

[表的选项];

temporapy表示新创建的表为临时表

表的选项用于描述如何春促引擎、字符集等选项

engine=存储引擎类型

default charset=字符集类型

2. 修改表结构:

1. 增加一个字段 :

//first 代表第一个位置

//after 代表在字段名2之后插入字段名1

alter table 数据表名

add ([][first|after已存在的字段名][,...])

2. 修改字段数据类型

alter table 数据表名

modify column([])

3. 修改字段名

alter table

change

4. 修改字段位置

alter table 数据表名

modify 字段名1 数据类型 first;

·······································

alter table 数据表名

modify 字段名1 数据类型 after 字段名;

first 代表第一个位置

after 代表在字段名2之后插入字段名1

5. 删除字段

alter table 数据表名

drop {column |}[,...]

alter table 数据表名

drop column 字段名;

6. 修改数据表名

alter table 数据表名

rename [as]

alter table 数据表名

rename [to]

7. 为指定的字段添加索引

alter table 数据表名

add index [索引名] (索引字段,...)

8. 删除索引

alter table 数据表名

drop index ;

数据表查看

1.查看数据库中所有表的信息

show tables;

show tables from 数据库名;

2.查看表结构

{describe | desc} [字段名];

例如:desc abc student;查看abc数据库中student数据表的表结构

或者desc student;查看当前数据库中student数据表的表结构

show columns from 表名;查看表结构

3.查看创建表时所输入的命令

show create table 表名;

4.删除数据表

drop table 表1,表2;

drop table if exists 表1,表2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值