【DB示例】如果数据库表不存在,则创建

1、oracle 数据库

declare  cnt number;

begin   

select count(*)into cnt from user_tables where table_name='ENTRY_MODIFYSTATUS';   

if cnt=0

then  execute immediate 'create table ENTRY_MODIFYSTATUS  (       

ENTRY_ID             VARCHAR2(18)                    not null,       

APPLY_TIME           DATE                            not null,       

STATUS               NUMBER(2),       

constraint PK_ENTRY_MODIFYSTATUS

primary key (ENTRY_ID, APPLY_TIME)     )';  

end if;   

cnt:=0;

end;

/

2、sqlserver数据库

use tam

go

IF  NOT EXISTS(SELECT  * FROM sysobjects WHERE name = 'sunzx' and type='U')

begin   

CREATE TABLE tam.[dbo].[sunzx] (    

[col1] int IDENTITY(1,1) NOT NULL,    

[col2] varchar(20) NULL    

)

end

go

3、mysql 数据库

create table if not exists OMSSM.TOKEN12(    

ID VARCHAR(255),    

USERID VARCHAR(255),    

  PRIMARY KEY ( ID )

);

原文地址:https://www.cnblogs.com/haifeisi/p/3259199.html