DDL 資料庫定義語言

2021-08-28 17:16:06 字數 806 閱讀 2572

建表

id name age

drop talbe if esists student

create table student(

id int primary keyauto_increment,

name varchar(20) not null,

age int not null default 18);

新增外來鍵約束

constraint fk_uid  foreign key  (字段) references  外來鍵的表(外來鍵表的字段)

新增聯合主鍵約束

primary key (欄位1,欄位2)

刪除表

drop table student;

修改表

增加字段(整數)

alter table student add height int;

修改字段(浮點數)

alter table student modify height double;

修改字段(欄位名,浮點數)

alter table student change height double;

刪除字段

alter table student drop column height;

資料庫定義語言DDL

sql是結構化查詢語句,sql是專門為資料庫而建立的操作命令集。是一種功能齊全的資料庫語言。在使用它時,只需要發出 做什麼 的命令,怎麼做 是不用使用者考慮的。ddl 資料定義語言 用來定義資料庫物件,建立庫 表 列等。dml 資料操作語言 用來運算元據庫表中的記錄 dql 資料查詢語言 用來查詢資...

DDL(資料庫定義語言)

ddl 資料庫定義語言 1.基本操作 檢視所有資料庫名稱 語法 show databases 切換資料庫 語法 use test 切換到test資料庫 顯示表 語法 show tables 查詢表 語法 select form goods 2.運算元據庫 2.1建立資料庫 create databs...

資料庫定義語言DDL

先來說一下資料庫的sql分類分別有哪些 ddl 資料庫定義語言 在資料庫中建立或刪除資料庫物件等操作如create,drop,alter dcl 資料庫控制語言 用來控制資料庫元件的訪問許可如grant,revoke dml 資料庫操作語言 用來插入,修改和刪除表中的資料,如insert,updat...