博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL--DDL
阅读量:4572 次
发布时间:2019-06-08

本文共 1579 字,大约阅读时间需要 5 分钟。

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_Kingdomon 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_Kingdomcreate 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 sanguoalter table sanguo addage 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 asselect [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_indexon sanguo([name])drop  index [sanguo].name_index

转载于:https://www.cnblogs.com/huangll/archive/2012/10/19/2730465.html

你可能感兴趣的文章
编写带有点击特效的UIButton
查看>>
使用mac版思维导图软件MindNode
查看>>
理解面向对象编程(OOP Object Oriented Programming)
查看>>
[題解]luogu_P1144最短路計數
查看>>
每日一个linux命令5 -- rm
查看>>
外存===内存
查看>>
node.js中的fs.appendFile方法使用说明
查看>>
URAL 1297 求最长回文字符串
查看>>
HDU 1098 Ignatius's puzzle 费马小定理+扩展欧几里德算法
查看>>
【C/C++】指针
查看>>
Anconda3导入TensorFlow报错,错误:h5py\__init__.py:36: FutureWarning
查看>>
js中return;、return true、return false;区别
查看>>
容器技术|Docker三剑客之docker-machine
查看>>
SQL注入理解与防御
查看>>
yum本地源配置
查看>>
3.4 C与汇编程序的相互调用
查看>>
浅析 JavaScript 链式调用
查看>>
分布式版本控制系统Git的安装与使用
查看>>
Python字符串反转操作
查看>>
js将时间戳转为时间格式
查看>>