• 基本的数据库操作脚本


    -- add column
    IF NOT  EXISTS (SELECT * FROM sys.columns WHERE name='WOAServedStatus' AND object_id=OBJECT_ID('WOA'))
    BEGIN
     ALTER table [WOA] add  WOAServedStatus INT NULL 
    END
    
    --增加一个约束 IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_WOA_WOAServedStatus]') AND type = 'D') BEGIN ALTER TABLE [dbo].[WOA] ADD CONSTRAINT [DF_WOA_WOAServedStatus] DEFAULT ((0)) FOR [WOAServedStatus] END --add foreign key IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WOA_WOAServedStatus]') AND parent_object_id = OBJECT_ID(N'[dbo].[WOA]')) BEGIN ALTER TABLE [dbo].[WOA] WITH CHECK ADD CONSTRAINT [FK_WOA_WOAServedStatus] FOREIGN KEY([WOAServedStatus]) REFERENCES [dbo].[WOAServedStatus] ([WSSIntNo]) ALTER TABLE [dbo].[WOA] CHECK CONSTRAINT [FK_WOA_WOAServedStatus] END --add index IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[WOA]') AND name = N'IX_WOA_WOAServedStatus') BEGIN CREATE NONCLUSTERED INDEX [IX_WOA_WOAServedStatus] ON [dbo].[WOA] ( [WOAServedStatus] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY] END
  • 相关阅读:
    Android 数据存储之 SQLite数据库存储
    Android 数据存储之 SharedPreferences储存
    Android 数据存储之 文件存储
    SSTABLE简介
    zookeeper原理
    改变win7驱动图标
    也谈谈拖延癌
    STM32f103之外部中断
    LPC1768/1769之CAN控制器概述(附库函数下载地址)
    Silicon C8051F340之时钟系统
  • 原文地址:https://www.cnblogs.com/sxjljj/p/8630634.html
Copyright © 2020-2023  润新知