sql语句
1.select * from table1
2.和、或者 and&or
3.order by 排序
select column1,column2 from table1 order by column1,column2 asc | desc
asc 升
desc降
4.插入一行 insert into 表名称 values(值1,值2)
5.更新 update 表名称 set 字段=新值
6.删除 delete from 表名 where 字段=值
7.limit、rownum取指定数目数据
MySQL:select * from table1 limit 5
Oracle:select * from table where rownum<5
8.like取带有相同内容数据
select * from table1 where column1 like '%a%' 带a的所有数据
select * from table1 where column1 like '_a_' 第二位为a的三位数据
9.in 取多个值
select * from table1 where column1 in (value1,value2)
10.between 范围内取值
select * from table1 where column1 between value1 and value2
11.表连接
select * from ab01 inner join ab02 on ab01.aab001=ab02.aab001
left join:从左表返回的所有行,在右表中没有匹配
12.union 合并sql语句
select sysdate from dual; --当前时间
字符到日期操作
select to_date('2023-03-06 16:16:09','yyyy-mm-dd hh24:mi:ss') from dual;
trunc 是对时间进行截取
select trunc(sysdate) from dual;
select trunc(sysdate,'yyyy') from dual; --取当年第一天
日期到字符操作
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual