zoukankan      html  css  js  c++  java
  • 【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 )

    );

  • 相关阅读:
    PAT1124:Raffle for Weibo Followers
    Pat1071: Speech Patterns
    PAT1032: Sharing (25)
    Pat1128:N Queens Puzzle
    C++相关:C++的IO库
    Pat1108: Finding Average
    PAT1070:Mooncake
    乐港游戏校招面试总结
    并发编程005 --- future &&futureTask
    并发编程004 --- 线程池的使用
  • 原文地址:https://www.cnblogs.com/haifeisi/p/3259199.html
Copyright © 2011-2022 走看看