Oracle笔记

Oracle笔记 - 图1

1.32位UUID

  1. select sys_guid() from dual;

上面生成的默认是大写字母组合数组,根据需要可以转换成小写:

  1. select lower(sys_guid()) from dual;

这里说一下Oraclelower函数作用(摘自Oracle官方文档):

LOWER returns char, with all letters lowercase. char can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The return value is the same datatype as char. The database sets the case of the characters based on the binary mapping defined for the underlying character set. For linguistic-sensitive lowercase, please refer to NLS_LOWER.

译:LOWER返回char,所有字母均小写。 char可以是CHAR,VARCHAR2,NCHAR,NVARCHAR2,CLOB或NCLOB的任何数据类型。 返回值是与char相同的数据类型。 数据库根据为基础字符集定义的二进制映射来设置字符的大小写。 有关语言敏感的小写字母,请参阅NLS_LOWER。

2.查找没有数据的表

在某些情况下我们需要知道哪些表是没有数据的

Oracle笔记 - 图2 sql如下:

  1. select * from all_all_tables
  2. where num_rows='0'
  3. and owner='USR_DC' and tablespace_name='TS_ZSJ_D';

select * from all_all_tables是查询Oracle所有的表,包括SYS用户下的,你可以根据表空间和所属用户来限制查询结果:

  1. where owner='所属用户' and tablespace_name='所属表空间'

想要查出没数据的话,all_all_tables中有个num_rows字段,记录该表数据是多少行的,rows='0'的肯定是没数据的