zoukankan      html  css  js  c++  java
  • Sql Server SQL语句创建数据库

    今天一个家伙说创建个数据库,搞了半天没弄好,习惯了图形界面,这些东西都忘了 全还给了老师。。。。。。

     1 USE [master]
     2 GO
     3 IF EXISTS(SELECT 1 FROM sysdatabases WHERE NAME=N'HkTemp')
     4 BEGIN
     5 DROP DATABASE HkTemp --如果数据库存在先删掉数据库
     6 END
     7 GO
     8 CREATE DATABASE HkTemp
     9 ON
    10 PRIMARY --创建主数据库文件
    11 (
    12 NAME='HkTemp',
    13 FILENAME='E:DatabasesHkTemp.dbf',
    14 SIZE=5MB,
    15 MaxSize=20MB,
    16 FileGrowth=1MB
    17 )
    18 LOG ON --创建日志文件
    19 (
    20 NAME='HkTempLog',
    21 FileName='E:DatabasesHkTemp.ldf',
    22 Size=2MB,
    23 MaxSize=20MB,
    24 FileGrowth=1MB
    25 )
    26 GO
    27 --添加表
    28 IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'Hksj_User') AND type in (N'U'))
    29 BEGIN
    30 CREATE TABLE Hksj_User
    31 (
    32 Id INT IDENTITY(1,1) NOT NULL,
    33 SName NVARCHAR(20) NOT NULL,
    34 SNickName NVARCHAR(20),
    35 SPassWord NVARCHAR(30) NOT NULL,
    36 DCreateDate DATETIME ,
    37 SCreator NVARCHAR(20),
    38 SEmail NVARCHAR(50),
    39 SPhone NVARCHAR(50),
    40 SIdentifyId NVARCHAR(30),
    41 DLastTimeLogOn DATETIME
    42 PRIMARY KEY CLUSTERED
    43 (
    44 Id ASC
    45 )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    46 ) ON [PRIMARY]
    47 END
    48 GO
    49 --添加注释
    50 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Hksj_User', @level2type=N'COLUMN',@level2name=N'SName'
    51 GO
    52 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Hksj_User', @level2type=N'COLUMN',@level2name=N'SEmail' 
  • 相关阅读:
    Visual Studio Reference Study.
    A Sample of communication between two processes
    BLE GATT 介绍
    BLE广播数据包分析
    geekuninstaller官方下载
    keil软件异常
    iBeacon data format
    Advertising and Scan Response Data Format
    Eclipse指定项目文件夹里.metadata文件夹的作用
    you must restart adb and eclipse的相关解决办法
  • 原文地址:https://www.cnblogs.com/sening/p/4524594.html
Copyright © 2011-2022 走看看