I can list the schemas names with PostgreSQL for example using the query:
select schema_name from information_schema.schemata
What query is equivalent for Oracle and SQLServer? Thank you very much!
I can list the schemas names with PostgreSQL for example using the query:
select schema_name from information_schema.schemata
What query is equivalent for Oracle and SQLServer? Thank you very much!
As of Oracle:
SQL> connect sys as sysdba
Enter password:
Connected.
SQL> select * from all_users;
USERNAME USER_ID CREATED
------------------------------ ---------- --------
XS$NULL 2147483638 29.05.14
MIKE 50 08.03.21
SCOTT 48 26.12.20
APEX_040000 47 29.05.14
APEX_PUBLIC_USER 45 29.05.14
FLOWS_FILES 44 29.05.14
<snip>
Don't know about MS SQL Server.
connect to database using SQLdeveloper or SQL developer then run the below query to fetch schema details
SELECT * FROM dba_users
In theory this should work the same on both Oracle and SQL Server as it does on Postgres. I know that it works on SQL Server, however on Oracle I vaguely recall that there's some trick or setting to access (or enable?) the INFORMATION_SCHEMA
tables.
Both Oracle and SQL Server also have their own custom system tables/views for stuff like this (sys.schemas
for SQL Server and dba_users
for Oracle, I think). SQL Server treats Schemas and Users as independent objects (Users can own Schemas) whereas Oracle treats them as different attributes/features of the same object (User == Schema), I'm not sure how Postgres does it.
Also, both SQL Server and Oracle will apply security "hiding" to objects that you do not have privs to see, even through INFORMATION_SCHEMA
. So if you are not supposed to be able to "View" a certain schema, then it won't appear to you in the INFORMATION_SCHEMA.SCHEMATA
table either. However, in many cases you are permitted to view metadata like this even when you are not permitted to access the objects themselves (depends on security settings).