多语言展示
当前在线:1414今日阅读:103今日分享:49

做报表需要知道的基本的SQL语句

为客户做报表需要操作数据库,基本的SQL是必须要掌握的,下面介绍做报表最常用的SQL语句。
方法/步骤
1

查询数据:编号表示查询顺序。(8) select (9) distinct (11) (1)from(3) join (2) on (4) where (5)group by (6) with {cube|rollup}(7)having(having_condition)(10) order by

2

向表中插入数据:insert into  table(field)  values (value)

3

把筛选后的数据插入到一张还不存在的临时表中:select * into 目标表 from 表 where ...

4

把筛选后的数据插入到一张已存在的临时表中:insert into 目的表 select * from 表 where 条件insert into  table1 (field1 )  Select field2 from table2

5

把A数据库的某个表的数据全部插新争入到B数据库摸侨的某个表中:select * into B.btable from A.atable where ...

6

修改表的某表的某字段类型和长度:alter table tablename  modify (name varchar2(20))

7

为某表增加字段:alter table 表名 ADD 字段名 类型

8

为某表修改字段名:alter table 表名 rename column A to B

9

为某表修改数据内容:update tablename set name =’张三‘ where name =’李四‘。该命令需要执行“commit”之后才会生效。

10

多艺辞泰张表更新:Update table1 set  table1.field 1=table2.field2  from table1,table2 where  table1.field3= table2 .filed3

11

删除某表某条数据:delete from table where condition

推荐信息