1、增:create(database、table、view、索引、觸發(fā)器)
Create database demo;創(chuàng)建名為demo的數(shù)據(jù)庫
Create table grb_order_20160711 (id varchar(20),name char(20),age int, birth date );創(chuàng)建表
2、刪:drop(database、table)
drop database demo;刪除名為demo的數(shù)據(jù)庫
drop table demo;刪除名為demo的表
3、改:alter(database、table、字段);修改database、table、字段名稱,增加/刪除字段(類型);
alter database ...>>改變數(shù)據(jù)庫的屬性,是物理的改變??梢钥吹靡姷?/p>
alter system ...>>改變實(shí)例的屬性,是邏輯性的改變,看不見的
alter table test add birthday date; 向 test 表中增加新的一列:birthday(data類型)
alter table test add sex varchar(10) not null; 添加有not null 約束的一個(gè)新字段(列)
alter table test add(modify) id varchar(10) primary key first; 添加新的帶有主鍵約束的字段并放在首位
alter table test add(modify) num varchar(20) after age; 添加num新字段并放在age后
alter table test rename demo;alter table 舊表名 rename [to] 新表名
alter table test change birthday birth datetime; alter table 表名 change 舊屬性名 新屬性名 新屬性類型(僅修改字段)
alter table test drop foreign key outkey;刪除外鍵
alter table test drop column column_name;刪除列(包括數(shù)據(jù)),delect刪除行
4、查:show(databases、tables)
show databases;查看創(chuàng)建好的數(shù)據(jù)庫
Show tables;查看數(shù)據(jù)庫中的所有表
5、用:use(database)
use demo;進(jìn)入demo數(shù)據(jù)庫








暫無數(shù)據(jù)