当前位置:网站首页>SQL Server(2)
SQL Server(2)
2022-07-05 17:29:00 【Game programming】
1. Create modification table ( Do not delete the original table , Make changes )
Add new column :alter table tb_student add Gender bit null
Delete old columns :alter table tb_student drop column Gender
Change column names :alter table tb_student alter column Gender bit null
Change column names : exec sp_rename 'tb_student.ClassNo','No','Column'
2. Create constraints
( Do not delete the original table , Create constraints )
alter table Table name add constraint PK_tb_student primary key ( Name )
alter table Table name add constraint FK_ Table name foreign key ( Name 1) references surface 2 name ( Name 2)
alter table Table name add constraint UK_ Table name _ Name unique( Name 1, Name 2)
alter table Table name add constraint CK_ Table name _ Name check( Conditional expression )
alter table Table name add constraint DK_ Table name default(0)for Name
3. insert data
A single piece of data is listed
insert (into) Table name ( Name 1, Name 2)values ( value 1, value 2,...)
insert (into) Table name ( Name 1, Name 2)select value 1, value 2....
union( be used for select Concatenation of insert statements )union all Allowing repetition is efficient
Multiple data listed
insert (into) Table name ( Name 1, Name 2)values ( value 1, value 2,...),( value 3, value 4,...),( value 5, value 6,...)
Clone data ( Copy data from one table to another )
1):insert Target table ( Name 1)select Name 2 from The original table
2):select Name 2 into surface 1 from surface 2
4. Update data
update Table name set Name 1= value where Name 2= value
( If not where Words , The data of the whole table has been modified )
5. Delete data
1):delete from Table name where Name = value
( Cause the value of the identification column to be discontinuous )
2):truncate table Table name ( Table data is cleared , Restore to initialization , The identity column is also restored )
truncate Efficient than delete high ,delete No data is deleted , Will be recorded in the log ,
,truncate No logging , Do not activate the trigger ,drop truncate It's instant operation
author : Late boat •
Game programming , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
边栏推荐
- 2022年信息系统管理工程师考试大纲
- Cartoon: looking for the k-th element of an unordered array (Revised)
- CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
- Rider 设置选中单词侧边高亮,去除警告建议高亮
- Three traversal methods of binary tree
- MySQL queries the latest qualified data rows
- mongodb(快速上手)(一)
- mysql5.6解析JSON字符串方式(支持复杂的嵌套格式)
- Domain name resolution, reverse domain name resolution nbtstat
- CMake教程Step2(添加库)
猜你喜欢
随机推荐
关于mysql中的json解析函数JSON_EXTRACT
mysql5.6解析JSON字符串方式(支持复杂的嵌套格式)
Cartoon: how to multiply large integers? (I) revised version
Independent development is a way out for programmers
C language to get program running time
About JSON parsing function JSON in MySQL_ EXTRACT
Rider 设置选中单词侧边高亮,去除警告建议高亮
Tips for extracting JSON fields from MySQL
ThoughtWorks global CTO: build the architecture according to needs, and excessive engineering will only "waste people and money"
MySQL之知识点(六)
The five most difficult programming languages in the world
stirring! 2022 open atom global open source summit registration is hot!
深入理解Redis内存淘汰策略
thinkphp模板的使用
Cartoon: a bloody case caused by a math problem
Cartoon: interesting [pirate] question
统计php程序运行时间及设置PHP最长运行时间
MySQL之知识点(七)
Summary of optimization scheme for implementing delay queue based on redis
Cmake tutorial step6 (add custom commands and generate files)