一、Oracle常用命令
- 1、set linesize 100; 设置长度
- 2、set pagesize 30; 设置每页显示数目
- 3、em a.sql 打开记事本
- 4、@ a 执行文件a中的代码,可指定文件的路径 @d:a.txt
- 5、conn 用户名/密码 根据用户名和密码连接数据库 如果连接超级管理员(sys) 则应加上as sysdba;
- 6、show user; 显示当前连接的用户
- 7、select * from tab; 得到当前用户下的所有表
- 8、desc temp; 查看表结构
- 9、/ 继续执行上一个查询语句
- clear scr; 清屏
- 字符函数
- 10、select upper('coolszy') from dual; 将小写字母转换成大写,dual 为一虚表
- 11、select lower('KUKA') from dual; 将大写字母转换成小写
- 12、select initcap('kuka') from dual; 将首字母大写
- 13、select concat('Hello',' world') from dual; 连接字符串,但没有||好用select concat('Hello','world') from dual;
- 14、select substr('hello',1,3) from dual; 截取字符串
- 15、select length('hello') from dual; 求字符串长度
- 16、select replace('hello','l','x') from dual; 替换字符串
- 17、select substr('hello',-3,3) from dual; 截取后三位
- 数值函数
- 18、select round(789.536) from dual; 四舍五入,舍去小数
- 19、select round(789.536,2) from dual; 保留两位小数
- 20、select round(789.536,-1) from dual; 对整数进行四舍五入
- 21、select trunc(789.536) from dual; 舍去小数,但不进位
- 22、select trunc(789.536,2) from dual;
- 23、select trunc(789.536,-2) from dual;
- 24、select mod(10,3) from dual; 返回10%3的结果
- 日期函数
- 25、select sysdate from dual; 返回当前日期
- 26、select months_between(sysdate,'16-6月 -08') from dual; 返回之间的月数
- 27、select add_months(sysdate,4) from dual; 在日期上加上月数
- 28、select next_day(sysdate,'星期一') from dual; 求下一个星期一
- 29、select last_day(sysdate) from dual; 求本月的最后一天
- 转换函数
- 30、select to_char(sysdate,'yyyy') year,to_char(sysdate,'mm'),to_char(sysdate,'dd') from dual;
- 31、select to_char(sysdate,'yyyy-mm-dd') from dual;
- 32、