1:刪除列
alter table 【表名字】 drop 【列名稱】
2:增加列
alter table 【表名字】 add 【列名稱】varchar(20) not null comment '注釋說明'
3:修改列的型別資訊
alter table 【表名字】 change 【列名稱】【新列名稱(這裡可以用和原來列同名即可)】 varchar(20) not null comment '注釋說明'
<2>
alter table 【表名字】 modify 【列名稱】 varchar(20) not null comment 『』
4:重新命名列
alter table 【表名字】 change 【列名稱】【新列名稱】 bigint not null comment '注釋說明'
5:重新命名表
alter table 【表名字】 rename 【表新名字】
6:刪除表中主鍵
alter table 【表名字】 drop primary key
7:新增主鍵
alter table sj_resource_charges add constraint pk_sj_resource_charges primary key (resid,resfromid)
《給已經生成的表新增外來鍵》
alter table tb_user add constraint eid foreign key(eid) references tb_em(eid);
8:新增索引
alter table sj_resource_charges add index index_name (name);
9: 新增唯一限制條件索引
alter table sj_resource_charges add unique emp_name2(cardnumber);
10: 刪除索引
alter table tablename drop index emp_name;
mysql 的基本語法 MYSQL基本語法
資料庫 可視為電子化的檔案櫃 儲存電子檔案的處所 為什麼使用資料庫 持久化 方便管理資料 結構化查詢 非結構化查詢 net start 程式 啟動 net stop 程式 結束 mysql uroot p3307 p 新建資料庫 create database 資料庫名 使用資料庫 use 資料庫名...
mysql的基本語法 mysql的基本語法
正文本篇文章主要是記錄一些常用的mysql語法,方便使用時候進行查閱。linux上常用命令 命令都以 結尾 1,登入mysql mysql u賬號 p密碼 2,檢視幫助 help 或者 h 3,檢視有哪些資料庫 show databases 4,進入某個資料庫 use databasename 5,...
MySql基本語法
基本語法 create database 資料庫名 資料庫選項 字符集等 基本語法 匹配模式 show create database 資料庫名 use 資料庫名 修改庫選項 alter database 資料庫名 選項 值 基本語法 drop 資料庫名 基本語法 create table 表名 欄...