ITPub博客

首页 > Linux操作系统 > Linux操作系统 > table

table

原创 Linux操作系统 作者:wgf19830218 时间:2011-05-20 11:59:42 0 删除 编辑

orders

ALTER TABLE PTC.ORDERS
 DROP PRIMARY KEY CASCADE;
DROP TABLE PTC.ORDERS CASCADE CONSTRAINTS;

CREATE TABLE PTC.ORDERS
(
  ORDERSID    VARCHAR2(10 BYTE),
  USERID      VARCHAR2(10 BYTE),
  ORDERDATE   DATE                              DEFAULT sysdate,
  PAYMODE     INTEGER                           DEFAULT 1,
  ISPAYED     INTEGER                           DEFAULT 0,
  TOTALPRICE  FLOAT(126)
)
TABLESPACE PDM_DATA_01
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          80K
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
NOMONITORING;

COMMENT ON COLUMN PTC.ORDERS.PAYMODE IS '1:貨到付款,2:網上付款';

COMMENT ON COLUMN PTC.ORDERS.ISPAYED IS '1:已付,0:未付';


CREATE UNIQUE INDEX PTC.ORDERS_PK ON PTC.ORDERS
(ORDERSID)
LOGGING
TABLESPACE PDM_DATA_01
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          80K
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER PTC.ORDERS_TRI
BEFORE INSERT
ON PTC.ORDERS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
BEGIN

   SELECT ORDER_SEQ.NEXTVAL INTO :NEW.ORDERSID FROM dual;
END ORDERS_TRI;
/


ALTER TABLE PTC.ORDERS ADD (
  CONSTRAINT ORDERS_PK
 PRIMARY KEY
 (ORDERSID)
    USING INDEX
    TABLESPACE PDM_DATA_01
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          80K
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

 

 

ordersdetails

DROP TABLE PTC.ORDERSDETAILS CASCADE CONSTRAINTS;

CREATE TABLE PTC.ORDERSDETAILS
(
  ORDERSID  VARCHAR2(10 BYTE),
  GOODSID   VARCHAR2(20 BYTE),
  NUMS      INTEGER
)
TABLESPACE PDM_DATA_01
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          80K
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
NOMONITORING;


ALTER TABLE PTC.ORDERSDETAILS ADD (
  FOREIGN KEY (ORDERSID)
 REFERENCES PTC.ORDERS (ORDERSID));

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22453766/viewspace-695823/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ESX3.5
下一篇: uploadFile
请登录后发表评论 登录
全部评论

注册时间:2009-09-01

  • 博文量
    38
  • 访问量
    45415