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语句

13.to_date、to_char、trunc

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

 

posted @   yj-newboy  阅读(32)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示