常用SQL_整理(1)

常用SQL_整理(1)

DIV1
查看表的全部信息,这个很简单

select * from 表名

表中有记录的行返回显示为1

select 1 from 表名```

统计有结果的行数

select count(1) from 表名 

DIV2
sql语句实现一个旧表oldTable中的数据直接备份到新表newTable

  1. SQLServer的用法

当newTable 表已经创建时:

insert into newTable select * from oldTable where...

当newTable 表还未创建时,也不想创建表结构了:

select * into newTable from oldTable
  1. Oracle的用法

当newTable 表已经创建时:

insert into newTable select * from oldTable where...

当newTable 表还没创建时:

create table newTable AS select * from oldTable  

DIV3
sql中使用in关键字查询结果集合并

select * from FIOPERATIONPARAMETER a where a.eventno in ('00000000000000006849','F0000000000000000031'); 

猜你喜欢

转载自blog.csdn.net/qq_37887131/article/details/86538824