1.查询某张表的所有字段:
select wm_concat(column_name) from all_tab_columns where table_name=upper('oms_customer_group');
2.给某张表添加字段及注释:
alter table oms_customer add(is_group char(1) default 0 not null);
3.imp userid=scott/tiger@orcl file=d:1.dmp(将dmp导入到库中)
4.decode函数
decode(pv.cost_type,1,'按次',2,'包时段',3,'按课时',4,'免费') as "计费类型",
5.to_char,to_date函数
语法:
TO_CHAR(date,’格式’)
TO_CHAR(string,’格式’)
例子:
将后台传入的string类型转成oracle数据库的date类型:to_date( #{accountDateEnd},'yyyy-MM-dd')
例如:select * from OMS_CUSTOMER_group t where t.create_time>to_date('2016/8/22','yyyy-mm-dd')
6.NUMBER ( precision, scale)
precision表示数字中的有效位。如果没有指定precision的话,Oracle将使用38作为精度。
scale表示数字小数点右边的位数,scale默认设置为0. 如果把scale设成负数,Oracle将把该数字取舍到小数点左边的指定位数
7.substr函数
语法:
substr( string, start_position, [ length ] )
例子:
SELECT substr('Thisis a test', 2, 2) FROM dual
8.删除oracle数据库中以xx开头的表(在sql中运行即可)
declare p_sql varchar2(4000);
begin
for r in (select a.TABLE_NAME from user_tables a where a.TABLE_NAME like 'VP_%') loop
p_sql:='drop table '||r.table_name;
execute immediate p_sql;
end loop;
end;
9.在命令窗口中导入表结构和表sql:
@d:\user.sql
10.Insert into Table2(field1,field2,...) select value1,value2,... from Table1
select wm_concat(column_name) from all_tab_columns where table_name=upper('oms_customer_group');
2.给某张表添加字段及注释:
alter table oms_customer add(is_group char(1) default 0 not null);
3.imp userid=scott/tiger@orcl file=d:1.dmp(将dmp导入到库中)
4.decode函数
decode(pv.cost_type,1,'按次',2,'包时段',3,'按课时',4,'免费') as "计费类型",
5.to_char,to_date函数
语法:
TO_CHAR(date,’格式’)
TO_CHAR(string,’格式’)
例子:
将后台传入的string类型转成oracle数据库的date类型:to_date( #{accountDateEnd},'yyyy-MM-dd')
例如:select * from OMS_CUSTOMER_group t where t.create_time>to_date('2016/8/22','yyyy-mm-dd')
6.NUMBER ( precision, scale)
precision表示数字中的有效位。如果没有指定precision的话,Oracle将使用38作为精度。
scale表示数字小数点右边的位数,scale默认设置为0. 如果把scale设成负数,Oracle将把该数字取舍到小数点左边的指定位数
7.substr函数
语法:
substr( string, start_position, [ length ] )
例子:
SELECT substr('Thisis a test', 2, 2) FROM dual
8.删除oracle数据库中以xx开头的表(在sql中运行即可)
declare p_sql varchar2(4000);
begin
for r in (select a.TABLE_NAME from user_tables a where a.TABLE_NAME like 'VP_%') loop
p_sql:='drop table '||r.table_name;
execute immediate p_sql;
end loop;
end;
9.在命令窗口中导入表结构和表sql:
@d:\user.sql
10.Insert into Table2(field1,field2,...) select value1,value2,... from Table1
要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量
11.linux环境下如何启动oracle命令:
su - oracle
123456
进入sqlplus:sqlplus /nolog
连接sysdba:conn /as sysdba
启动数据库:startup
测试是否可以访问数据库:select sysdate from dual;
select * from dual;
退出sql:exit
打开监听:lsnrctl start
exit-
12.将数据结果保留两位小数正数显示:
abs(to_char(sdc.amt, 'FM99999990.0099')) amt,
13.获取当天数据:
to_char(sdc.changedate, 'yyyy-mm-dd') = to_char(sysdate, 'yyyy-mm-dd')
切换root用户,关闭防火墙
su -
123456
service iptables stop
linux中是ifconfig查看ip地址,windows是ipcoinfig
查看path的配置:echo %path%