首页 > 数据库技术 > 详细

MySQL语法练习一

时间:2014-03-30 23:34:00      阅读:804      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
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
bubuko.com,布布扣

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

MySQL语法练习一

原文:http://www.cnblogs.com/zhangyongjian/p/3634210.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!