当前位置:网站首页>SQL Server(2)
SQL Server(2)
2022-07-05 16:59:00 【游戏编程】
1.创建修改表(不删除原来表的基础上,进行修改)
添加新列:alter table tb_student add Gender bit null
删除旧列:alter table tb_student drop column Gender
修改列名:alter table tb_student alter column Gender bit null
修改列名: exec sp_rename 'tb_student.ClassNo','No','Column'
2. 创建约束
(不删除原有表的基础上,创建约束)
alter table 表名 add constraint PK_tb_student primary key (列名)
alter table 表名 add constraint FK_表名 foreign key (列名1) references 表2名(列名2)
alter table 表名 add constraint UK_表名_列名 unique(列名1,列名2)
alter table 表名 add constraint CK_表名_列名 check(条件表达式)
alter table 表名 add constraint DK_表名 default(0)for 列名
3.插入数据
单条数据列入
insert (into)表名(列名1,列名2)values (值1,值2,...)
insert (into)表名(列名1,列名2)select 值1,值2....
union(用于select插入语句的连用)union all允许重复效率高
多条数据列入
insert (into)表名(列名1,列名2)values (值1,值2,...),(值3,值4,...),(值5,值6,...)
克隆数据 (将一张表的数据复制到另一种表上)
1):insert 目标表(列名1)select 列名2 from 原表
2):select 列名2 into 表1 from 表2
4. 更新数据
update 表名 set 列名1=值 where 列名2=值
(如果不加where的话,整张表的数据都修改了)
5.删除数据
1):delete from 表名 where 列名=值
(造成标识列的值不连续)
2):truncate table 表名(表数据清空,恢复到初始化,标识列也恢复)
truncate效率比delete高,delete没删除一条数据,都会在日志里记录,
,truncate不会记录日志,不激活触发器,drop truncate是即时操作
作者:晚舟•
游戏编程,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
边栏推荐
- 机器学习01:绪论
- 漫画:如何实现大整数相乘?(整合版)
- Machine learning 01: Introduction
- Machine learning 02: model evaluation
- 33: Chapter 3: develop pass service: 16: use redis to cache user information; (to reduce the pressure on the database)
- Domain name resolution, reverse domain name resolution nbtstat
- Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
- Learn about MySQL transaction isolation level
- Machine learning compilation lesson 2: tensor program abstraction
- 力扣解法汇总1200-最小绝对差
猜你喜欢

Embedded -arm (bare board development) -1

CMake教程Step1(基本起点)

【性能测试】jmeter+Grafana+influxdb部署实战

ICML 2022 | Meta提出魯棒的多目標貝葉斯優化方法,有效應對輸入噪聲

CVPR 2022 best student paper: single image estimation object pose estimation in 3D space

Judge whether a string is a full letter sentence

ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声

33: Chapter 3: develop pass service: 16: use redis to cache user information; (to reduce the pressure on the database)

WR | 西湖大学鞠峰组揭示微塑料污染对人工湿地菌群与脱氮功能的影响

Kafaka技术第一课
随机推荐
C # realizes crystal report binding data and printing 3-qr code barcode
Tips for extracting JSON fields from MySQL
蚂蚁金服的暴富还未开始,Zoom的神话却仍在继续!
独立开发,不失为程序员的一条出路
Little knowledge about C language (array and string)
Rider 设置选中单词侧边高亮,去除警告建议高亮
Which is more cost-effective, haqu K1 or haqu H1? Who is more worth starting with?
关于mysql中的json解析函数JSON_EXTRACT
CMake教程Step4(安装和测试)
Embedded -arm (bare board development) -1
7.Scala类
Cmake tutorial step6 (add custom commands and generate files)
Debug kernel code through proc interface
Embedded-c language-6
MYSQL group by 有哪些注意事项
goto Statement
Embedded-c Language-2
【7.7直播预告】《SaaS云原生应用典型架构》大咖讲师教你轻松构建云原生SaaS化应用,难题一一击破,更有华为周边好礼等你领!
CMake教程Step3(添加库的使用要求)
Cloud security daily 220705: the red hat PHP interpreter has found a vulnerability of executing arbitrary code, which needs to be upgraded as soon as possible