mysql表复制,索引,视图

复制表


insert into t1 select * from t2;//表的结构一定要完整


create table t2 like t1; //学习表结构


insert into t1 select * from t2;//结构一样时可以这么操作


insert into t1(name) select name from t2;
=====================================================
索引


创建和删除索引
 
create index  名称 on 表名称(列)


drop index 名称 on 表名


//以上这两种不常用,但是不能创建主键的索引
show index from t1;
//查看表的索引
以下为常用创建方法
alert table t1 add index 名称(列)


alert table t1 drop index 名称


alert table t1 modify id int unsinged not null;//去掉自增


alert table t1 drop primary key;//删除主键 


alert table t1 add unique 名称(列);创建唯一索引


alert table t1 add primary key (列)增加主键索引 


alert table t1 modify id int unsigned not null auto_increment; //增加自增,无符号
======================================================
mysql 视图


create view v_t1 as select * from t1 where id>4 and id<8;
======================================================
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值