運算元據庫 表

2021-09-25 04:34:41 字數 990 閱讀 6045

1、連線到mysql伺服器

mysql -u使用者名稱 -p
2、檢視全部資料庫

show databases;
3、選擇要操作的資料庫

use 資料庫名稱;
4、檢視某個資料庫的所有表

show tables;
運算元據庫

建立資料庫

create database 資料庫名稱;
刪除資料庫

drop database 資料庫名稱;
操作表

建立表

create table 表名(型別名稱1 型別 primary key, 型別名稱2 型別);
修改表名

alter table 原表名 rename 新錶名
檢視表的定義/檢視表的定義的sql語句

desc 表名;
show create table 表名 \g;
修改表的型別

alter table 表名 modify 型別名稱 型別;
增加表字段型別

alter table 表名 add column 型別名稱 型別;
修改表字段型別的名稱

alter table 表名 change 原型別名稱 新型別名稱 型別;
刪除表字段型別

alter table 表名 drop column 型別名稱;
刪除表

drop table 表名;

MySQL運算元據庫表

1,建立表的時候寫注釋 create table if not exists demo dictionary id varchar 32 not null comment 主鍵id primary key,dictionary name varchar 100 not null comment 名稱...

DDL 運算元據庫 表

1 c create 建立 建立資料庫 create database 資料庫名稱 建立資料庫,判斷不存在,再建立 create database if not exists 資料庫名稱 建立資料庫,並指定字符集 create database 資料庫名稱 character set 字符集名 2 ...

Mysql DDL 運算元據庫 表

一 運算元據庫 crud 1.c create 建立 建立資料庫 create database 資料庫名稱 建立資料庫,判斷不存在,再建立 create database if not exists 資料庫名稱 建立資料庫,並指定字符集 create database 資料庫名稱 characte...