数据库练习

1、使用mysqldump命令备份数据库中的所有表

2、备份booksDB数据库中的books表

3、使用mysqldump备份booksDB和test数据库

4、使用mysql命令还原第二题导出的books表

5、进入数据库使用source命令还原第二题导出的book表

二、索引

1、建立一个utf8编码的数据库test1
mysql> create database test1 character set utf8;
2、建立商品表goods和栏目表category
mysql> create table goods(
       goods_id int(11) primary key auto_increment,
       goods_name varchar(20) not null,
       cat_id int(11) not null,
       brand_id int(11) not null,
       goods_sn char(12) not null,
       shop_price float(6,2) not null,
       goods_desc text) engine=myisam charset=utf8;
mysql> create table category(
       cat_id int(11) primary key auto_increment,
       cate_name varchar(20) not null,
       parent_id int(11) not null) engine=myisam charset=utf8;
3、删除 goods 表中的 goods_desc 字段及货号字段,并增加 click_count 字段 

4、在 goods_name 列上加唯一性索引(用alter table方式) 

5、在 shop_price 列上加普通索引(用create index方式)
mysql> create index s_price on goods(shop_price);
6、在 click_count 上增加普通索引,然后再删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值