showglobal variables like"%datadir%";select @@basedir;select @@datadir;/usr/bin/mysql --verbose --help | grep -A 1 'Default options'Default options are readfrom the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
select*from product_info t
where t.create_time
between'2020-05-23 00:00:00'and'2020-05-23 17:39:52';
或
select*from product_info t
where t.create_time
between str_to_date('2020-05-23 00:00:00','%Y-%m-%d %H:%i:%s')and str_to_date('2020-05-23 17:39:52','%Y-%m-%d %H:%i:%s');
3 将一个表中的字段的值更新到另一个表
1、使用子查询方式:
update tablea a
set a.bname =(select b.name from tableb b where b.id=a.bid)where 各种约束条件;
缺点:数据量大的时候,非常慢;
2、多表合并方式1:
update tablea a, tableb b
set a.bname=b.name
where a.bid=b.id;
使用第二种方式比第一种方式要快许多;
当然如果数据量很多的话,可以创建索引提速;
3、多表合并方式2:
update h_log_load a innerjoin h_log_load b
on a.load_prov=b.load_prov AND a.load_tab=b.load_tab AND a.load_date=b.load_date
set a.load_rs=b.load_stat;
-- 判断表中是否存在这个字段,不存在就新增
if not exists(select * from information_schema.columns t where t.table_schema ='oam' and t.table_name ='v_school_info' and t.column_name='pr2oject_desc')
begin
select111;
end
GO
-- 判断表中是否存在这个字段,存在就删除
if exists(select * from sys.columns where name='字段名称' and [object_id]=object_id(N'表名'))
begin
ALTER TABLE 表名 DROP COLUMN 字段名称;
end
GO
mysql将一个字段的值复制到另一个字段update h_log_load a inner join h_log_load b on a.load_prov=b.load_prov AND a.load_tab=b.load_tab AND a.load_date=b.load_date set a.load_rs=b.load_stat;...