Example 1
List a small set of created tables
This is a good example of a concept page with engine-specific SQL rather than one universal statement.
Engine-specific syntax
Setup
CREATE TABLE alpha (id INT);
CREATE TABLE beta (id INT);SQL
SELECT
table_name AS table_name
FROM
information_schema.tables
WHERE
table_schema = DATABASE ()
AND table_name IN ('alpha', 'beta')
ORDER BY
table_name;| table_name |
|---|
| alpha |
| beta |
Engine-specific syntax
Setup
CREATE TABLE alpha (id INT);
CREATE TABLE beta (id INT);SQL
SELECT
TABLE_NAME
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE = 'BASE TABLE'
AND TABLE_NAME IN ('alpha', 'beta')
ORDER BY
TABLE_NAME;| TABLE_NAME |
|---|
| alpha |
| beta |
Engine-specific syntax
Setup
CREATE TABLE alpha (id INT);
CREATE TABLE beta (id INT);SQL
SELECT
table_name
FROM
information_schema.tables
WHERE
table_schema = 'public'
AND table_name IN ('alpha', 'beta')
ORDER BY
table_name;| table_name |
|---|
| alpha |
| beta |
Engine-specific syntax
Setup
CREATE TABLE alpha (id INT);
CREATE TABLE beta (id INT);SQL
SELECT
name
FROM
sqlite_master
WHERE
type = 'table'
ORDER BY
name;| name |
|---|
| alpha |
| beta |
The row values are equivalent, but the query shape and generated column labels differ by engine.