当前位置:网站首页>SQL statement of SQL server creates database
SQL statement of SQL server creates database
2022-07-26 11:30:00 【Baby paper d】
Let's explain first Sql The function of symbols in sentences , Otherwise, when you see this series of representations, you will not know how to write them in the database and , This symbol book does not need to be written into the database , Just write the contents | |
| [ ] | This square bracket indicates whether this item can be written or not |
| { } | Braces indicate that this item must be written |
| | | The vertical bar is used to separate each item , Indicates one of the options |
| [, ...n] | Indicates that the previous item can be n Secondary repetition ,“ , ” Used to separate each item |
| <> | What is in angle brackets is usually a label , Others represent grammatical chunks , In other words, the contents of this label can be written in multiple |
| () | If expressed in parentheses , When writing code, the parentheses are also It should be written into the code Of , He is not a sign , Do not omit |
| in addition , stay sql In the sentence is Case insensitive Of ! Generally, the characters specified by the system will be capitalized , But I was confused when I saw the capital letters , So I usually use lowercase , Also use lowercase here , It's more comfortable to look at and remember . | |
One more point , In use SQL When writing the database, you will not know where the code is written , Actually , Or write code directly in the new query , But note that the database code that has been executed cannot be executed again , Because it has been created , You cannot create a database with the same name again ( The same is true of data tables ). Then select , Re execution , It can be executed paragraph by paragraph .
sql Statement create database
creat database < Database name > ( Directly define the name when building the database , Don't have to add <>)
[ ON -- ON It is used to store data files
[ < filespec >[ , . . . n ] ] -- there filespec Is a label block , It refers to data files or log files
]
[ Log on -- Log on It is used to store log files
{ <filespec>[ , . . . n ] }
]
among , Data files or log files include : file name 、 File storage location 、 Initial size 、 The maximum capacity 、 Growth capacity , Where initial size 、 The maximum capacity 、 Increasing capacity can be omitted , It will be established by default .
-- File format
[ primary ] -- Specify the file as the main file , A database can only have one master file , If not, the first file will be the main file by default
(
name = file name ,
filename = ' File name storage location ' ,
[ , size = n ]
[ , maxsize = { m | unlimited } ] --n,m It can be directly numerical , The default unit is MB
[ , filegrowth = g ] -- Increasing capacity can be used KB、MB perhaps % To represent the
)
-- When writing code , To write this section to Yes < filespec > label The location of
Nothing can be understood by a piece of code
CREATE DATABASE Librarys
ON
(
NAME = library,
FILENAME = 'E:\Library.mdf',
SIZE = 5,
MAXSIZE = 20
)
LOG ON
(
NAME = library_log,
FILENAME = 'E:\Librarylog.ldf',
SIZE = 1,
MAXSIZE = 10
)SQL Statement to modify the database
After creating a database, you can't directly change the content and re create it again ( Not deleted ), So we need to write additional code to modify the database
alter database < Database name >
{
Add File < filespec > [ , . . . n ] [ to filegroup Filegroup name ] -- Add a new file
| remove file file name -- Delete this file
| modify file < filespec > -- Make changes to the file ,Ps: Specify in the file name, You can only change size or maxsize or filegrowth, and size The size of is larger than the original
| Add log file < filespec > -- Add log file
| modify name = New database name -- Rename the database
}
Delete database
Drop database Database name [ , . . . n ] -- Delete database
Using this statement to delete will delete all the contents of this database file on the disk , And the confirmation message will not appear before deletion , So be careful to use this statement .
边栏推荐
- QT——LCDNumber
- Pyechart离线部署
- Shape matching Halcon template
- 3Dunity游戏项目实战——飞机大战
- Basic concepts of JVM and memory management model
- List ascending and descending
- Leetcode-209. subarray with the smallest length (binary, prefix and, sliding window)
- Connection between PLC and servo motor
- 由浅入深搭建神经网络
- 1748. Sum of unique elements
猜你喜欢
随机推荐
MySQL deadlock analysis
QT - connect USB camera
PyQt5快速开发与实战 3.1 Qt Designer快速入门
Ten year structure five year life-06 impulse to leave
easyui02
Scrapy ip代理无响应
Blue screen problem in win10 1903 notebook hot spot
Want the clouds in the picture to float? Video editing services can be achieved in three steps with one click
Getting started step by step using g2o to solve ICP problems - estimating the transformation relationship between two sets of 3D point sets with matching relationship
找工作4个月,面试15家,终于拿到3个offer,定级P7+
MongoDB-使用$type查询某个字段的类型是否为xxx
After 4 months of job search and 15 interviews, I finally got 3 offers, ranking P7+
How to configure the jdbcrealm data source?
Synchronized与ReentrantLock
[报错]看日志看什么
社区点赞业务缓存设计优化探索
MySQL事务详解
Understanding of Abstract Programming
On vio's IMU pre integration (the idea when I first started)
pytest pytest. Ini configuration case grouping case skipping






![[idea] how to create a new project](/img/33/f210d59ccd3664487f401929dac24c.png)


