WEB开发网
开发学院数据库MySQL MySQL for Linux on POWER 数据库创建简介 阅读

MySQL for Linux on POWER 数据库创建简介

 2008-01-18 11:06:45 来源:WEB开发网   
核心提示: -- Creating the databaseCREATE DATABASE CONTRACTING;-- Changing into the CONTRACTING databaseUSE CONTRACTING;-- Creating table JOBCREATE TABLE JO

-- 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;

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:MySQL for Linux

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接