create table temp_table as select * from sys.sales;
创建一个表,名为temp_table,借用sys.sales表的数据结构,并把sys.sales表数据插入到temp_table中
create table temp_table1 as select * from sys.sales where rownum < 1;
创建一个表,名为temp_table1,借用sys.sales表的数据结构.
create table t_stock_regulate --(创建表)
(
id number(15) not null primary key,
bill_id varchar2(20),
dept_id number(15),
person varchar2(20),
bill_person varchar2(20),
regulate_date date,
create_date date DEFAULT sysdate
);
CREATE SEQUENCE s_stock_regulate --(创建序列)
START WITH 1
MAXVALUE 999999999999999
INCREMENT BY 1
NOCACHE
CYCLE;
create or replace procedure stock_regulate_id (son_id out t_stock_regulate.id%type) is --(创建或修改一个过程)
p_id t_stock_regulate.id%type ;
begin
SELECT s_stock_regulate.NEXTVAL INTO p_id FROM DUAL;
son_id := p_id;
end;
create table t_stock_regulatema --(创建一表)
(
id number(15) not null primary key,
bill_id number(15),
dept_id number(15),
materiel_id number(15),
price number(19,6),
before_price number(19,6)
);
CREATE SEQUENCE s_stock_regulatema --(创建一序列)
START WITH 1
MAXVALUE 999999999999999
INCREMENT BY 1
NOCACHE
CYCLE;
CREATE OR REPLACE TRIGGER tr_stock_regulatema --(创建或修改一个触发器:内容:把序列挂到表中使表的ID成为唯一性)
BEFORE INSERT
ON t_stock_regulatema
FOR EACH ROW
DECLARE
NEW_ID NUMBER;
BEGIN
SELECT s_stock_regulatema.NEXTVAL INTO NEW_ID FROM DUAL;
:NEW.ID := NEW_ID;
END;
/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/109975/viewspace-604098/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/109975/viewspace-604098/