MYSQL課程設計:圖書管理系統!(基礎知識之表的的建立與刪除!)

MYSQL:
查詢支持的所有引擎
數據庫

show engines;

在這裏插入圖片描述
查詢默認的存儲引擎:
spa

show variables like 'storage_engine%';
//或
show variables like 'storage%';

在這裏插入圖片描述
建立數據表:
3d

create [temporary] table [if not exists] #();
//temporary:建立一個臨時表;

在這裏插入圖片描述
查看錶:
code

show tables;//#:數據庫名

在這裏插入圖片描述
查看錶結構:
blog

show columns from hello_01 frim hello;

在這裏插入圖片描述

describe #;

在這裏插入圖片描述

describe hello_01 id;
//或
desc hello_01 id;

在這裏插入圖片描述
修改表:
添加列:

圖片

alter table hello_01
add password varchar(20);

在這裏插入圖片描述
修改列:
table

alter table hello_02
modify name varchar(30);

在這裏插入圖片描述
刪除列:
class

alter table hello_01
drop password;
//或
alter table hello_01
drop column name;

在這裏插入圖片描述
在這裏插入圖片描述
查詢表數據:

bfc

select * from hello_02;

在這裏插入圖片描述
重命名錶:
select

rename table #1 to #2;

在這裏插入圖片描述
複製表:

//不復制數據
create table hello_02copy like hello_02;

在這裏插入圖片描述

//且複製數據:
create table hello_02copy01 as select * from hello_02;

在這裏插入圖片描述
刪除表:

drop table hello_02copy01;
//或
drop table hello_02copy01;

drop table if exists hello_02copy;

在這裏插入圖片描述
在這裏插入圖片描述

相關文章
相關標籤/搜索