一、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%';
7.查询JSON字符串中key查询Value:
SELECT JSON_VALUE(json_column, '$.key') AS value FROM your_table;
二、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