oracle 建立表 序列 注釋 主鍵

2021-09-01 05:17:48 字數 2495 閱讀 1776

declare

icount number(2) := 0;

begin

select count (*) into icount from user_sequences u where u.sequence_name = 'seq_tcapitalnotify';

if icount = 0

then

/*建立序列*/

execute immediate 'create sequence seq_tcapitalnotify minvalue 1 nomaxvalue start with 1 increment by 1';

end if;

select count (*) into icount from user_tables u where u.table_name = 'tcapitalnotify';

if icount = 0

then

/*建立表tcapitalnotify*/

execute immediate 'create table tcapitalnotify(

l_serialno number(11) not null primary key,

d_date date not null,

c_custno varchar2(12) not null,

f_balence number(16,2),

c_fundcode varchar2(6),

d_replypaytime date,

c_orgcontact varchar2(2000),

c_orgtel varchar2(2000),

d_notificationtime date,

c_iscertificate char(1),

c_realpaytime date,

c_memo char(1),

c_iscancel varchar2(2000),

c_creator varchar2(16),

d_createdate date

) nologging tablespace crm_htable';

execute immediate 'comment on table tcapitalnotify is ''資金通知情況表''';

execute immediate 'comment on column tcapitalnotify.l_serialno is ''序列號''';

execute immediate 'comment on column tcapitalnotify.d_date is ''日期''';

execute immediate 'comment on column tcapitalnotify.c_custno is ''賬戶名稱''';

execute immediate 'comment on column tcapitalnotify.f_balence is ''購買資金(元)''';

execute immediate 'comment on column tcapitalnotify.c_fundcode is ''購買產品''';

execute immediate 'comment on column tcapitalnotify.d_replypaytime is ''機構答覆資金劃撥時間''';

execute immediate 'comment on column tcapitalnotify.c_orgcontact is ''機構聯絡人''';

execute immediate 'comment on column tcapitalnotify.c_orgtel is ''機構聯絡**''';

execute immediate 'comment on column tcapitalnotify.d_notificationtime is ''我方通知時間''';

execute immediate 'comment on column tcapitalnotify.c_iscertificate is ''是否提供劃款憑證''';

execute immediate 'comment on column tcapitalnotify.c_realpaytime is ''資金實際到賬時間''';

execute immediate 'comment on column tcapitalnotify.c_iscancel is ''撤單''';

execute immediate 'comment on column tcapitalnotify.c_memo is ''備註''';

execute immediate 'comment on column tcapitalnotify.c_creator is ''建立人''';

execute immediate 'comment on column tcapitalnotify.d_createdate is ''建立日期''';

end if;

end;

/

oracle 建立表 序列 注釋 主鍵

declare icount number 2 0 begin select count into icount from user sequences u where u.sequence name seq tcapitalnotify if icount 0 then 建立序列 execute ...

oracle建立表 注釋

建表的時候為了以後查詢方便,也為了減少資料庫文件的編寫,建表最好加上表的注釋和列的注釋 建表語句 create table table count table name varchar2 40 char not null enable,count varchar2 40 char not null ...

Oracle建立序列,表

create sequence name increment by x x為增長間隔 start with x x為初始值 maxvalue x x為最大值 minvalue x x為最小值 cycle 迴圈使用,到達最大值或者最小值時,從新建立物件 cache x 制定快取序列值的個數 乙個例子 ...