mysql 數據庫定義常用操作

//數據庫名暫定爲:db
1.創建數據庫
create database db default character set utf8;

2.使用數據庫
use db;

3.刪除數據庫
drop database db;

4.修改數據庫的字符集
alter database db default charset utf8;

5.查看建立數據庫的語句
show create database db;

6.建立一個表,查看其默認值
create table t(t int);

7.建立表
create table t1(
tid int unsigned not null auto_increment,
tname varchar(30) not null,
primary key(tid)
)auto_increment=201401;

8.刪除表
drop table t1;

9.批量刪除多個表
drop table t1,t2,t3;

10.修改表名
rename table t1 to student;

11.修改表中字段的類型及字段名
alter table student change tname sname varchar(30) not null;

12.增加一列
alter table student add saddress varchar(50) after sname;

13.刪除列
alter table student drop column saddress;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章