DDL相关语句练习

输入密码登录mysql,创建数据库zoo,转换到zoo数据库

mysql> create database zoo character set gbk;
mysql> use zoo

查看创建数据库zoo信息

mysql> show create database zoo;

删除数据库zoo

mysql> drop database zoo

先创建数据库db_system,接着创建两张表

create table user(
id int primary key auto_increment comment 'id',
NAME char(20) not null comment '姓名',
gender char(4) not null comment '性别',
birthday date comment '生日',
entry_date date not null comment '入职时间',
job char(30) not null comment '职位');

>create table salary(
->id int primary key auto increment comment'id',
->userld int not null comment'用户id',
->basesalary float not null comment'基本工资',
->month int not null comment'月份',
->allowances float not null default 0 comment'补贴');

alter的基本命令,add、modify、drop、rename、change......

1、mysql>alter table user add image tinyblob

2、mysql> alter table user modify job varchar(60);

3、mysql> alter table user drop column gender;

4、mysal> alter table salary rename usersalary

5、mysql> alter table user convert to character set utf8.

6、mysql> alter table user change column name username char(20) not null,

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值