MySQL语法练习一

DESC t_dept

ALTER TABLE t_dept
ADD descri VARCHAR(20)

ALTER TABLE t_dept
ADD decribe VARCHAR(20) FIRST

ALTER TABLE t_dept
ADD descr VARCHAR(100)
AFTER deptno

ALTER TABLE t_dept
DROP descri

ALTER TABLE t_dept
DROP decribe

DESCRIBE t_dept

ALTER TABLE t_dept
MODIFY descr INT

DESC t_dept

ALTER TABLE t_dept
CHANGE descr me INT

DESC t_dept

ALTER TABLE t_dept
CHANGE me he VARCHAR(100)

DESC t_dept

ALTER TABLE t_dept
MODIFY he VARCHAR(100) FIRST
DESC t_dept


ALTER TABLE t_dept
MODIFY he VARCHAR(100) 
AFTER loc

DESC t_dept

DROP TABLE t_dept

CREATE TABLE t_dept(
deptno INT NOT NULL,
dname VARCHAR(20),
loc VARCHAR(40)
)

DESC t_dept

DROP DATABASE test1

CREATE DATABASE company;
USE company;
CREATE TABLE t_dept(
deptno INT NOT NULL,
dname VARCHAR(20) DEFAULT cjgong,
loc VARCHAR(40)
)

DROP DATABASE company
CREATE DATABASE company;
USE company

CREATE DATABASE t_dept(
deptno INT,
dname VARCHAR(20) UNIQUE,
loc VARCHAR(40)
)

DESC t_dept;

CREATE TABLE t_dept(
deptno INT,
dname VARCHAR(20),
loc VARCHAR(40),
CONSTRAINT uk_name UNIQUE(dname)
);

CREATE TABLE t_dept(
deptno INT,
dname VARCHAR(20),
loc VARCHAR(40),
CONSTRAINT pk_name PRIMARY KEY(dname)
)
CREATE DATABASE company;
USE company

CREATE TABLE t_dept(
deptno INT,
dname VARCHAR(20),
loc VARCHAR(40),
CONSTRAINT pk_dname_deptno PRIMARY KEY(deptno,dname)
)

CREATE DATABASE company;
USE company;

CREATE TABLE t_dept(
deptno INT PRIMARY KEY AUTO_INCREMENT,
dname VARCHAR(20),
loc  VARCHAR(40)
)
ALTER TABLE t_dept
ADD deptno1 INT;

CREATE TABLE t_employee(
empno INT PRIMARY KEY,
ename VARCHAR(20),
job VARCHAR(40),
MGR INT,
Hiredate DATE,
sal DOUBLE(10,2),
comm DOUBLE(10,2),
deptno INT,
CONSTRAINT fk_deptno FOREIGN KEY(deptno)
REFERENCES t_dept(deptno)
);

DESC t_employee

DESC t_dept

MySQL语法练习一,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。