zoukankan      html  css  js  c++  java
  • SQLDDL

    DDL (Data Discription Language) 数据库定义语言

    basic object operation
    Create Alter Drop
     database   create database         drop database
     table create table  alter table   drop table
     view  create view    drop view  
     index  create index    drop index

    DataBase

    View Code
    create database Three_Kingdom
    on primary (
    name='Three_Kingdom_data',
    filename='d:\Three_Kingdom.mdf',
    size=3mb,
    maxsize=100mb,
    filegrowth=2%
    
    )
    log on(
    name='Three_Kingdom_ldf',
    filename='d:\Three_Kingdom.ldf',
    size=1mb,
    maxsize=50mb,
    filegrowth=2
    )
    
    /*drop database*/
    drop database Three_Kingdom
     primary:指定主文件组中的文件。
     log on:指明事务日志文件的明确定义。
     name:指定数据库的逻辑名称
     filename :指定数据库文件.mdf.ndf的名称和路径。
     size:数据库初始容量。
     maxsize:数据库最大容量。
     filegrowth:指定文件每次增加容量的大小,当指定为0时,表示文件不增长。可以按百分比增长、数值增长。

    Table

    View Code
    use Three_Kingdom
    create table sanguo(
    id smallint identity(1,1),
    [number] nvarchar(5) not null, 
    [name] nvarchar(10) not null,
    [address] nvarchar (20) default'地址不详',
    email nvarchar(20) check(email like'%@%'),
    country nchar(1) check(country like'[魏蜀吴]')
    primary key(number),
    constraint cons_num check(number like'[0-9][0-9][0-9]')
    )
    
    drop table sanguo
    
    alter table sanguo add
    age int not null,
    salary decimal(6,2) default 3200,
    constraint cons_age check (age>20)
    
    alter table sanguo 
    drop constraint cons_age,column age

     View

    View Code
    create view V_Profile as
    select [sanguo].[number],[sanguo].[name],[sanguo2].[zi]
    from [sanguo],[sanguo2]
    where[sanguo].[number]=[sanguo2].[number]
    
    
    drop view V_profile

    Index

    View Code
    create nonclustered index name_index
    on sanguo([name])
    
    drop  index [sanguo].name_index
  • 相关阅读:
    Timer定时任务
    spring boot配置多数据源
    消费者模块调用提供者集群报错
    修改windHost文件
    spring常用注解+Aop
    添加ClustrMaps
    无题
    2020年3月21日 ICPC训练联盟周赛,Benelux Algorithm Programming Contest 2019
    2020年3月14日 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019
    2020.4.12 个人rating赛 解题+补题报告
  • 原文地址:https://www.cnblogs.com/huangll/p/2730465.html
Copyright © 2011-2022 走看看