MySQL视图、索引添加删除

1、复制表结构

MariaDB [yzmedu]> create table student like user;

2、把user表的内容插入到student表里

MariaDB [yzmedu]> insert into student select * from user;

3、查看索引

MariaDB [yzmedu]> show index from user\G

普通索引

创建索引

MariaDB [yzmedu]> create index i_age on user(age);

删除索引

MariaDB [yzmedu]> drop index i_age on user;

创建视图

MariaDB [yzmedu]> create view userclass as select user.username,user.age,class.name from user,class where user.class_id=class.id;


删除视图

MariaDB [yzmedu]> drop view userclass;

 

 

你可能感兴趣的:(MySQL视图、索引添加删除)