常用sql查询

一、oracle

1.复制表结构及数据:create table new_table as select * from old_table;

2.只复制表结构:create table new_table as select * from old_table where 1<>1;

3.to_date & to_char函数  to_date('2023-02-24,13:25:59','yyyy-mm-dd,hh24:mi:ss');

to_char(sysdate,'yyyy-mm-dd hh24:mi:ss');

4.添加表字段,默认值,注释  alter table 表名  add 字段 number(1,0)  default '0';

comment  on  column  表名.字段名   is  '注释内容';

comment on table 表名  is  '注释内容';

5.修改字段属性  alter table 表名 modify 字段 varchar(3) default '1' ;

6.存储结构查询关键字 

select t.name,t.text from all_source t where type = 'PROCEDURE'
  and text like '%keywords%';

二、mysql 

1.查询当天数据  select * from 表名 where to_days(日期字段) = to_days(now());

2. to_char()函数  DATE_FORMAT(NOW(),'%m-%d-%Y');

3.查询昨天数据  TO_DAYS( NOW( ) ) - TO_DAYS( create_time) <= 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值