Using information schema
1 2 3 4 5
SELECT table_schema, table_name FROM information_schema.tables;
Taking the look at the columns of a certain table using information scehma
1 2 3 4 5 6 7 8
SELECT table_name, column_name, data_type FROM information_schema.tables WHERE table_name = 'pg_config';
Creating new tables with
CREATE TABLE
Syntax:
1 2 3 4 5
CREATE TABLE table_name ( column_a data_type, column_b data_type, column_c data_type );
- Example:
1 2 3 4 5
CREATE TABLE weather ( clouds text, temperature numeric, weather_station char(5) )
- Example:
INSERT INTO statemnt
1 2
INSERT INTO table_name (column_a, column_b) VALUES ("value_a", "value_b");
RENAME a column
1 2
ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
DROP a column
1 2
ALTER TABLE table_name DROP COLUMN column_name;
Relational Databases
This post is licensed under CC BY 4.0 by the author.
Contents