SQL知识体系总体介绍.pptVIP

  • 38
  • 0
  • 约7.3千字
  • 约 19页
  • 2018-05-17 发布于四川
  • 举报
维涛 (SQL知识体系总体介绍) 一、基本的数据类型 二、四种基本操作 三、表关联 四、 视图 表 触发器 五、 函数 存储过程 六、游标 七、 分析器使用 提纲: 基本的数据类型 常用数据类型: 整形:int bigint 字符型:char varchar 浮点型:money float decimal 日期类型:datetime 时间戳:timestamp 二进制数据类型 image (图片) 四种基本操作 插入 insert 例1: insert into @table(a,b) values(1,1) 例2: insert into @table(a,b) select 1,1 from imatgeneral 更新 update update @table set a=2 update @table set a=b.a from @table a inner join @temp b on a.a=b.a 删除 delete Delete from @table where a=‘1’ 四种基本操作 检索    SELECT * FROM imatgeneral select top 10 * from imatgeneral select percent 50 * from imatgeneral declare @matcode varchar(30) select @matcode=matcode from imatgeneral where oldcode=‘123’ select @matcode 表关联介绍 ,连接 Select a.a,b.b from imatgeneral a ,ibatchgeneral b where a.matcode=b.matcode Left jion Select a.a,b.b from imatgeneral a left join ibatchgeneral b on a.matcode=b.matcode Inner join Select a.a,b.b from imatgeneral a inner join ibatchgeneral b on a.matcode=b.matcode Right join Select a.a,b.b from imatgeneral a right join ibatchgeneral b on a.matcode=b.matcode Full join Select a.a,b.b from imatgeneral a full join ibatchgeneral b on a.matcode=b.matcode cross join 表 视图 触发器 表  〔外键关系,索引〕  create table mutest(a varchar(30),b varchar(50),primary key(a)) 例子: CREATE TABLE [dbo].[gUOM]( [uom] [varchar](30) NOT NULL, [uomname] [varchar](40) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [pk_guom] PRIMARY KEY CLUSTERED ( [uom] ASC ) ) ON [PRIMARY] 注意:表名不能以_sp,_uf结尾和以v开头 索引: create index ind_guom on guom(uomname) 视图 表 触发器 表: 索引: create index ind_guom on guom(uomname) 表是否有主键(默认情况下所有表都必须有主键) 常用索引是否已建立(提高系统性能) 表 视图  触发器 视图  create view v_imatgeneral as select … 例子: create view [dbo].[vsalestnbaseprice] as select a.tncode, a.oldcode,a.matcode, a.matname, b.tobeprice1,b.tobeprice2, b.tobeprice3, b.tobeprice4, b.modifydate, b.modi

文档评论(0)

1亿VIP精品文档

相关文档