Showing Tables In DBMS: SQL*Plus vs. DB2 vs. MySQL vs. PostGreSQL

Showing Tables In DBMS: SQL*Plus vs. DB2 vs. MySQL vs. PostGreSQL

server-1235959_640

Showing Tables In Oracle SQL*Plus

Connecting to the database

sqlplus username/password@database-name

Listing tables owned by current user type

select tablespace_name, table_name from user_tables;

Listing all tables in the database

select tablespace_name, table_name from dba_tables;

Listing tables accessible to the current user

select tablespace_name, table_name from all_tables;

or

select owner, table_name from all_tables

or

select owner, table_name from dba_tables

or

select table_name from user_tables

Describing a table  

desc <table_name>

Additional notes

For more information on the different table-related commands available to you, see Oracle’s official documentation.

Showing Tables in MySQL

Connecting to the database

mysql [-u username] [-h hostname] database-name

Choosing the correct database

First, Type show databases.

Next, choose the database you want to manipulate with use <database-name>

Listing all tables in the current database

show tables

Listing all tables on the current server

show full tables

Showing a specific table

select object_name from user_objects where object_type = ‘TABLE';

Describing a table

desc <table-name>

Additional notes  

More information on tables can be found in the official MySQL Documentation. Note that unlike SQL*Plus, most of the additional functionality here is only available through MySQL extensions.

Showing Tables in DB2

Connecting to the database

db2 connect to <database-name>

Listing all tables in the database

db2 connect to <database-name>

Listing the currently-active schema

db2 get schema.

Note: click here for more information on schemas.  

Changing the schema

db2 set schema=<schema_name>

or

db2 create schema <schema_name> authroization <inst_user>

Listing all tables in the currently-active schema

db2 list tables for schema <schema-name>

Describing a table

db2 describe table <table-schema.table-name>

Additional notes  

You can learn more about DB2’s tables functionality in IBM’s official documentation.

Showing Tables in PostgreSQL

Connecting to the database

psql [-U username] [-h hostname] database-name

Listing all databases

\l

or

\list

Listing all tables in the current database

\dt

Describing a table

\d <table-name>

Additional notes  

To learn more about what you can do with tables in PostgreSQL, read the official documentation.


Subscribe with Feedly