MySQL语法练习一

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语法练习一

MySQL语法练习一,布布扣,bubuko.com

MySQL语法练习一

上一篇:hibernate 之 sql查询


下一篇:PL/SQL database character set