mysql欄位更改操作命令

2022-08-02 02:33:10 字數 909 閱讀 9707

1) 加索引

mysql> alter table 表名 add index 索引名 (欄位名1[,欄位名2 …]);

例子: mysql> alter table employee add index emp_name (name);

2) 加主關鍵字的索引

mysql> alter table 表名 add primary key (欄位名);

例子: mysql> alter table employee add primary key(id);

3) 加唯一限制條件的索引

mysql> alter table 表名 add unique 索引名 (欄位名);

例子: mysql> alter table employee add unique emp_name2(cardnumber);

4) 刪除某個索引

mysql> alter table 表名 drop index 索引名;

例子: mysql>alter table employee drop index emp_name;

5) 增加字段

mysql> alter table table_name add field_name field_type;

6) 修改原欄位名稱及型別

mysql> alter table table_name change old_field_name new_field_name field_type;

7) 刪除字段

mysql alter table table_name drop field_name;

mysql 說明字段命令 mysql基本操作命令

1 資料庫基本操作命令 1 檢視所有資料庫 show databases 2 檢視當前使用的資料庫 select database 3 建立資料庫 create database 資料庫名 chaset utf8 4 使用資料庫 use 資料庫名 5 刪除資料庫 慎重 drop database 資...

mysql 字段操作

1.新增字段 alter table 表名 add 列名 型別 約束 例 alter table students add birthday datetime 2.修改字段 1 修改欄位名 alter table 表名.table name rename column old column name...

Mysql 字段操作

alter table 表名 add 欄位1 型別 長度 欄位2 型別 長度 欄位3 型別 長度 alter table pro add add pro int 11 pro age int 11 pro lenth int 11 alter table pro add drop column ag...