List of tables by owner.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 30 Sep 2014 19:13:46 +0300
changeset 1624 baf11017516f
parent 1623 4496f9e49b7b
child 1625 0fa6542d8c93
List of tables by owner.
oracle.rst
--- a/oracle.rst	Tue Sep 30 19:09:41 2014 +0300
+++ b/oracle.rst	Tue Sep 30 19:13:46 2014 +0300
@@ -44,9 +44,19 @@
 Database info.
 ==============
 
+List of users::
+
+  select distinct(OWNER) from ALL_TABLES;
+
 List of current user owned tables::
 
   select * from USER_TABLES;
+  select TABLE_NAME from USER_TABLES;
+
+List of tables by owner::
+
+  select OWNER || '.' || TABLE_NAME from ALL_TABLES
+    order by OWNER;
 
 List of current user table sizes::
 
@@ -66,6 +76,14 @@
     group by index_name, table_name
     order by table_name;
 
+List of tables without primary keys::
+
+  select OWNER || '.' || TABLE_NAME from ALL_TABLES
+    where TABLE_NAME not in (
+      select distinct TABLE_NAME from ALL_CONSTRAINTS where CONSTRAINT_TYPE = 'P'
+    ) and OWNER in ('USER1', 'USER2')
+    order by OWNER, TABLE_NAME;
+
 List of currenct user constraints::
 
   select * from USER_CONSTRAINTS;