SQL Server简单语句/待整理
2015-06-12 12:50
323 查看
数据库对象:表Table,视图View,存储过程Stored Procedure,触发器Trigger
关系:1关系=1二维表,1关系有1关系名。1关系=1表对象
属性/字段: 二维表中垂直方向的列 元组/记录:二维表中水平方向的行
码/关键字:二维表中某个属性(侯选码) , 值唯一标识1元祖 该属性为侯选码。若1关系有多侯选码,则选其一为主码/主属性
关系模式:描述关系的,它包括关系名、组成该关系的属性名和属性到域的映像。=关系名(属性名1,属性名2,…,属性名n)
select name , sex , Entrancescore from student where Entrancescore between 500 and 600
【从表中取出仅这三列 分500-600间】
create database databse_name
drop database databse_name
alter table tabname add col1 int 加int型col1列
alter table tabname add primary key (col1) 加主键
alter table tb_text add primary key(列1) 加列1为主键(前提notnull)
create table tabname(col1 int not null primary key) 主键col表tabname
select * into tbnew from tboldname 旧表建新表(主键要设)
select * into tbnew from tboldname where 1=2 建和旧表类型一样的
alter table table1 alter column col varchar 改字段col 类型
alter table table1 drop column col 删字段
alter table table1 add col char(200) 加字段
select top 10 * from M2box_Structure1 前10条
select top 10 * from table1 order by newid() 随机取10条
select count(*)as 学生总数 from student 【统计学生总数,并以"学生总数"字段名命名】
select avg(Entrancescore) as 平均成绩 from student
select max(Entrancescore) as 入学最好成绩 from student
DELETE FROM M2box_Structure1 删除所有的行
select * into table2 from table1 where 1=2 只复制表结构不复制数据;where 1= 1所有的都符合,where 1=2表示都不符合。
关系:1关系=1二维表,1关系有1关系名。1关系=1表对象
属性/字段: 二维表中垂直方向的列 元组/记录:二维表中水平方向的行
码/关键字:二维表中某个属性(侯选码) , 值唯一标识1元祖 该属性为侯选码。若1关系有多侯选码,则选其一为主码/主属性
关系模式:描述关系的,它包括关系名、组成该关系的属性名和属性到域的映像。=关系名(属性名1,属性名2,…,属性名n)
select name , sex , Entrancescore from student where Entrancescore between 500 and 600
【从表中取出仅这三列 分500-600间】
create database databse_name
drop database databse_name
alter table tabname add col1 int 加int型col1列
alter table tabname add primary key (col1) 加主键
alter table tb_text add primary key(列1) 加列1为主键(前提notnull)
create table tabname(col1 int not null primary key) 主键col表tabname
select * into tbnew from tboldname 旧表建新表(主键要设)
select * into tbnew from tboldname where 1=2 建和旧表类型一样的
alter table table1 alter column col varchar 改字段col 类型
alter table table1 drop column col 删字段
alter table table1 add col char(200) 加字段
select top 10 * from M2box_Structure1 前10条
select top 10 * from table1 order by newid() 随机取10条
select count(*)as 学生总数 from student 【统计学生总数,并以"学生总数"字段名命名】
select avg(Entrancescore) as 平均成绩 from student
select max(Entrancescore) as 入学最好成绩 from student
DELETE FROM M2box_Structure1 删除所有的行
select * into table2 from table1 where 1=2 只复制表结构不复制数据;where 1= 1所有的都符合,where 1=2表示都不符合。
相关文章推荐
- SQL常用操作
- SQL常用操作 2015-06-12 12:43 20人阅读 评论(0) 收藏
- SQL Server 2008 清空删除日志文件
- MongoDB查询命令详解
- Oracle安装笔记
- java操作redis数据库
- Mysql编程基础
- mysql concat拼接函数
- oracle同义词创建(synonym)
- mysql 关键字-保留字
- 删除数据库中重复记录的SQL语句
- 从数据库层面理解:随机 I/O & 顺序 I/O
- MYSQL数据库学习十一 多表数据记录查询
- oracle 触发器
- mongodb评论回复的相关设计
- IRedisClient
- oracle时间精确到毫秒
- sql 的递归含下级查询(同一张表)
- Redis IRedisTypedClient
- Oracle时间转换输入输出