MySQL CREATE TABLE EMPLOYEE_TBL ( EMP_ID VARCHAR(9) NOT NULL, LAST_NAME VARCHAR(15) NOT NULL, FIRST_NAME VARCHAR(15) NOT NULL, MIDDLE_NAME VARCHAR(15), ADDRESS VARCHAR(30) NOT NULL, CITY VARCHAR(15) NOT NULL, STATE CHAR(2) NOT NULL, ZIP INTEGER(5) NOT NULL, PHONE CHAR(10), PAGER CHAR(10), CONSTRAINT EMP_PK PRIMARY KEY(EMP_ID) ); CREATE TABLE EMPLOYEE_PAY_TBL ( EMP_ID VARCHAR(9) NOT NULL PRIMARY KEY, POSITION VARCHAR(15) NOT NULL, DATE_HIRE DATE, PAY_RATE DECIMAL(4,2), DATE_LAST_RAISE DATE, SALARY DECIMAL(8,2), BOUNS DECIMAL(6,2), CONSTRAINT EMP_FK FOREIGN KEY(EMP_ID) REFERENCES EMPLOYEE_TBL(EMP_ID) ); CREATE TABLE CUSTOMER_TBL ( CUST_ID VARCHAR(10) NOT NULL PRIMARY KEY, CUST_NAME VARCHAR(30) NOT NULL, CUST_ADDRESS VARCHAR(20) NOT NULL, CUST_CITY VARCHAR(15) NOT NULL, CUST_STATE CHAR(2) NOT NULL, CUST_ZIP INTEGER(5) NOT NULL, CUST_PHONE CHAR(10), CUST_FAX INTEGER(10) ); CREATE TABLE ORDERS_TBL ( ORD_NUM VARCHAR(10) NOT NULL PRIMARY KEY, CUST_ID VARCHAR(10) NOT NULL, PROD_ID VARCHAR(10) NOT NULL, QTY INTEGER(6) NOT NULL, ORD_DATE DATE ); CREATE TABLE PRODUCTS_TBL ( PROD_ID VARCHAR(10) NOT NUL PRIMARY KEY, PROD_DESC VARCHAR(40) NOT NULL, COST DECIMAL(6,2) NOT NULL ); Oracle and SQL Server CREATE TABLE EMPLOYEE_TBL ( EMP_ID VARCHAR(9) NOT NULL, LAST_NAME VARCHAR(15) NOT NULL, FIRST_NAME VARCHAR(15) NOT NULL, MIDDLE_NAME VARCHAR(15), ADDRESS VARCHAR(30) NOT NULL, CITY VARCHAR(15) NOT NULL, STATE CHAR(2) NOT NULL, ZIP INTEGER NOT NULL, PHONE CHAR(10), PAGER CHAR(10), CONSTRAINT EMP_PK PRIMARY KEY(EMP_ID) ); CREATE TABLE EMPLOYEE_PAY_TBL ( EMP_ID VARCHAR(9) NOT NULL PRIMARY KEY, POSITION VARCHAR(15) NOT NULL, DATE_HIRE DATE, PAY_RATE DECIMAL(4,2), DATE_LAST_RAISE DATE, SALARY DECIMAL(8,2), BOUNS DECIMAL(6,2), CONSTRAINT EMP_FK FOREIGN KEY(EMP_ID) REFERENCES EMPLOYEE_TBL(EMP_ID) ); CREATE TABLE CUSTOMER_TBL ( CUST_ID VARCHAR(10) NOT NULL PRIMARY KEY, CUST_NAME VARCHAR(30) NOT NULL, CUST_ADDRESS VARCHAR(20) NOT NULL, CUST_CITY VARCHAR(15) NOT NULL, CUST_STATE CHAR(2) NOT NULL, CUST_ZIP INTEGER NOT NULL, CUST_PHONE CHAR(10), CUST_FAX VARCHAR(10) ); CREATE TABLE ORDERS_TBL ( ORD_NUM VARCHAR(10) NOT NULL PRIMARY KEY, CUST_ID VARCHAR(10) NOT NULL, PROD_ID VARCHAR(10) NOT NULL, QTY INTEGER NOT NULL, ORD_DATE DATE ); CREATE TABLE PRODUCTS_TBL ( PROD_ID VARCHAR(10) NOT NULL PRIMARY KEY, PROD_DESC VARCHAR(40) NOT NULL, COST DECIMAL(6,2) NOT NULL );
Oracle和MySQL中都运行了,可以正确执行。