当前位置:网站首页>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内核浏览器。
边栏推荐
- 【二叉树】根到叶路径上的不足节点
- 【7.7直播预告】《SaaS云原生应用典型架构》大咖讲师教你轻松构建云原生SaaS化应用,难题一一击破,更有华为周边好礼等你领!
- EasyX second lesson
- 【性能测试】全链路压测
- 查看自己电脑连接过的WiFi密码
- Is it safe for qiniu business school to open a stock account? Is it reliable?
- ICML 2022 | Meta propose une méthode robuste d'optimisation bayésienne Multi - objectifs pour faire face efficacement au bruit d'entrée
- Tita 绩效宝:如何为年中考核做准备?
- Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
- ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise
猜你喜欢

WR | 西湖大学鞠峰组揭示微塑料污染对人工湿地菌群与脱氮功能的影响
Summary of optimization scheme for implementing delay queue based on redis

ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise

How to write a full score project document | acquisition technology

机器学习02:模型评估
MYSQL group by 有哪些注意事项
Example tutorial of SQL deduplication

统计php程序运行时间及设置PHP最长运行时间

激动人心!2022开放原子全球开源峰会报名火热开启!

MySQL之知识点(七)
随机推荐
激动人心!2022开放原子全球开源峰会报名火热开启!
启牛商学院股票开户安全吗?靠谱吗?
Design of electronic clock based on 51 single chip microcomputer
The first lesson of EasyX learning
哈趣K1和哈趣H1哪个性价比更高?谁更值得入手?
Machine learning 02: model evaluation
Judge whether a number is a prime number (prime number)
Thoughtworks 全球CTO:按需求构建架构,过度工程只会“劳民伤财”
Summary of optimization scheme for implementing delay queue based on redis
力扣解法汇总729-我的日程安排表 I
ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise
网上办理期货开户安全吗?网上会不会骗子比较多?感觉不太靠谱?
Embedded UC (UNIX System Advanced Programming) -2
MySQL之知识点(七)
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
Is it safe and reliable to open futures accounts on koufu.com? How to distinguish whether the platform is safe?
2022 年 Q2 加密市场投融资报告:GameFi 成为投资关键词
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
MySql 查询符合条件的最新数据行
C (WinForm) the current thread is not in a single threaded unit, so ActiveX controls cannot be instantiated