Portable SQL/Statements/Access metadata/Views

From Linuxnetworks
Jump to: navigation, search

ANSI

SQL-92 defines a collection of objects in INFORMATION_SCHEMA which contains the list of available views:

SELECT table_name
FROM information_schema.views

Firebird/Interbase

SELECT DISTINCT RDB$VIEW_NAME
FROM RDB$VIEW_RELATIONS

MS SQL Server

SELECT name
FROM sys.views

MySQL

Fully compatible with SQL-92.

Oracle

SELECT view_name
FROM user_views

PostgreSQL

SELECT table_name
FROM information_schema.views
WHERE
 table_name !~ '^pg_' AND
 table_schema NOT IN ('pg_catalog', 'information_schema')

SQLite

Doesn't support retrieving views via an SQL statement.

Sybase ASE

EXEC sp_tables @table_type = "'VIEW'", @table_owner = "dbo"