檢視 新增表索引

2021-10-24 18:21:58 字數 1279 閱讀 6574

show index from sys_user

alter table `sys_user` add unique test(`salt`,`password`,`phone`) comment '這是唯一索引'
修改原有欄位名稱及型別:

alter table bulletin change uid username varchar(50) not null default '';

新增新字段:

alter table bulletin add citycode varchar(6) not null default 0; # 城市**

1.建立資料庫時設定編碼

create database test character set utf8;

2.建立表時設定編碼

create table test(id int primary key)default charset=utf8;

3.修改資料庫編碼

alter database test character set utf8;

4.修改表預設編碼

alter table test character set utf8;

5.修改字段編碼

alter table test modify col_name varchar(50) character set utf8;

新增索引方法

1.新增primary key(主鍵索引)

mysql>alter table `table_name` add primary key ( `column` )

2.新增unique(唯一索引)

mysql>alter table `table_name` add unique (

`column`

)3.新增index(普通索引)

mysql>alter table `table_name` add index index_name ( `column` )

4.新增fulltext(全文索引)

mysql>alter table `table_name` add fulltext (

`column`

)5.新增多列索引

mysql>alter table `table_name` add index index_name ( `column1`, `column2`, `column3`

mysql 表 索引 mysql 為表新增索引

索引作用 在索引列上,除了上面提到的有序查詢之外,資料庫利用各種各樣的快速定位技術,能夠大大提高查詢效率。特別是當資料量非常大,查詢涉及多個表時,使用索引往往能使查詢速度加快成千上萬倍。例如,有3個未索引的表t1 t2 t3,分別只包含列c1 c2 c3,每個表分別含有1000行資料組成,指為1 1...

MySql索引的使用操作 新增 刪除 檢視索引

在表中建立索引,以便更加快速高效地查詢資料 使用者無法看到索引,它們只能被用來加速搜尋 查詢 更新乙個包含索引的表需要比更新乙個沒有索引的表更多的時間,這是由於索引本身也需要更新。因此,理想的做法是僅僅在常常被搜尋的列 以及表 上面建立索引。alter table table name add in...

Oracle檢視某個表的索引

select from user ind columns where table name upper agent master agent master為表名 建立主鍵 alter table qc master add primary key agent code 的時候oracle會自動建立索...