mysql脚本模式创建索引_mysql创建脚本索引范例
查看表中索引的方法:
show index from table_name; 查看索引
索引的類型及創建例子::
1.PRIMARY KEY (主鍵索引)
alter table table_name add primary key ( `column` );
2.UNIQUE 或 UNIQUE KEY (唯一索引)
alter table table_name add unique (`column`);
3. 刪除索引
alter table 表名 drop index 索引名;
4.INDEX (普通索引)
alter table table_name add index index_name ( `column` );
5.多列索引 (聚簇索引)
alter table `table_name` add index index_name ( `column1`, `column2`, `column3` );
6.修改表中的索引:
alter table `table_name` drop primary key,add primary key(`column1`, `column2`);
修改列名 增加列明
1.添加字段:
alter table `tablename` Add column `column` int not null default 0;
2.刪除字段:
alter table `tablename` drop column `column`;
3.調整字段順序:
ALTER TABLE `tablename` CHANGE `column1` `column1` int not null default 0 AFTER `column2`;
4.重命名列
alter table `tablename` change `column1` `column2` integer;
5.改變列的類型
alter table `tablename` change ?`column1` ?`column1` bigint not null;
6.修改字段
alter table 表名 change 舊字段名 新字段名 字段類型;
alter table 表名 modify 字段名 字段類型;//修改字段類型
alter table student change name name varchar(20)not null default 'liming';//修改字段類型 default后邊是
字段默認的值
alter table student change name name1 varchar(20)not null default 'liming';//修改字段名
總結
以上是生活随笔為你收集整理的mysql脚本模式创建索引_mysql创建脚本索引范例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab 点云特征_基于点云的3D障
- 下一篇: iPhone 14 Pro/Pro Ma