數據庫入門常用命令

數據庫操作:

查看所有數據庫:show databases;

創建數據庫:create database test_database;

刪除某個數據庫:drop database test_database;

使用某個數據庫:use test_database;

表操作:

查看所有表:show tables;

創建表:create table test_table(

    屬性名 數據類型,

    屬性名 數據類型,

    ......

)

查看錶結構:describe test_table;

查看錶詳細結構:show create tabel test_table;

刪除表:drop table test_table;

修改表名:alter table old_table rename [to] new_table;

在表中增加字段:alter table test_table add 屬性名 數據類型;

在表中第一個位置增加字段:alter table test_table add 屬性名 數據類型 first;

在表中指定位置後增加字段:alter table test_table add 屬性名 數據類型 after 屬性名;

刪除字段: alter table test_table drop 屬性名;

修改字段的數據類型:alter table test_table modify 屬性名 數據類型;

修改字段名:alter table test_table change 舊屬性名 新屬性名 舊數據類型;

同時修改字段名喝屬性:alter table test_table change 舊屬性名 新屬性名 新數據類型;

修改字段的順序:alter table test_table  modify 屬性名1 數據類型  first|after 屬性名2;  first 表示將字段調整到表首位,after 屬性名2 表示將字段調整到屬性名2的後邊。

 

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