MySQL for Linux on POWER 数据库创建简介
2008-01-18 11:06:45 来源:WEB开发网-- Creating the database
CREATE DATABASE CONTRACTING;
-- Changing into the CONTRACTING database
USE CONTRACTING;
-- Creating table JOB
CREATE TABLE JOB (
JOB_CODE INTEGER NOT NULL UNIQUE,
JOB_NAME LONG VARCHAR NOT NULL,
JOB_HOUR_CHRG DECIMAL(10,2) NOT NULL,
PRIMARY KEY (JOB_CODE)) ENGINE=InnoDB;
-- Creating table EMPLOYEE
CREATE TABLE EMPLOYEE (
EMP_SSN CHAR(9) NOT NULL UNIQUE,
EMP_LNAME VARCHAR(50) NOT NULL,
EMP_FNAME VARCHAR(50) NOT NULL,
JOB_CODE INTEGER NOT NULL,
PRIMARY KEY (EMP_SSN),
FOREIGN KEY (JOB_CODE) REFERENCES JOB(JOB_CODE)
ON UPDATE CASCADE
ON DELETE RESTRICT) ENGINE=InnoDB;
-- Creating table PROJECT
CREATE TABLE PROJECT (
PRJ_NUM INTEGER NOT NULL UNIQUE,
PRJ_NAME VARCHAR(50) NOT NULL,
EMP_SSN CHAR(9) NOT NULL,
PRIMARY KEY (PRJ_NUM),
FOREIGN KEY (EMP_SSN) REFERENCES EMPLOYEE(EMP_SSN)
ON UPDATE CASCADE
ON DELETE RESTRICT) ENGINE=InnoDB;
-- Creating table ORDERFORM
CREATE TABLE ORDERFORM (
ORD_NUM INTEGER NOT NULL UNIQUE,
ORD_DATE DATE NOT NULL,
ORD_HOURS SMALLINT NOT NULL,
ORD_CHRG_HOUR DECIMAL(10,2) NOT NULL,
ORD_CHARGE DECIMAL(10,2) NOT NULL,
PRJ_NUM INTEGER NOT NULL,
EMP_SSN CHAR(9) NOT NULL,
PRIMARY KEY (ORD_NUM),
FOREIGN KEY (EMP_SSN) REFERENCES EMPLOYEE(EMP_SSN)
ON UPDATE CASCADE
ON DELETE RESTRICT,
FOREIGN KEY (PRJ_NUM) REFERENCES PROJECT(PRJ_NUM)
ON UPDATE CASCADE
ON DELETE RESTRICT) ENGINE=InnoDB;
更多精彩
赞助商链接