Oracle创建表结构

来源:互联网 发布:js隐藏button 编辑:程序博客网 时间:2024/06/05 11:06
下面是创建Oracle数据表的例子,本人最近才学Oracle,有不足之处,请积极发表评论指正,不甚感激!
 
declare i number;  begin  select count(*) into i from user_tables where table_name = 'LOGINUSER';  //判断是否存在table,类似于SQL,详见我的SQLSERVER模块if i = 0 thenexecute immediate 'Create Table LOGINUSER(Id number, UserName nvarchar2(255),Password varchar2(255),Role number)';end if;end; /declare i number;  beginselect count(*) into i from all_sequences where SEQUENCE_NAME = 'LOGINUSERID_SEQ'; //类似与定义SQL中的 ID int identify(1,1); if i = 0 thenexecute immediate 'create sequence LOGINUSERID_SEQminvalue 1maxvalue 999999999999999999999999999start with 1increment by 1nocache';end if;end;/