PostgreSQL DDL Operations: Difference between revisions
Jump to navigation
Jump to search
Line 31: | Line 31: | ||
psql | psql | ||
\du | \du | ||
=Tablespace= | |||
==List Tablespaces== | |||
psql | |||
\db | |||
=Tables= | |||
==List Tables== | |||
psql | |||
\dt | |||
==Create a Table== | |||
CREATE TABLE poc_library_component | |||
( | |||
"id" integer NOT NULL, | |||
"name" text, | |||
"desc" text, | |||
CONSTRAINT poc_library_component_pk PRIMARY KEY (id) | |||
) | |||
WITH ( | |||
OIDS=FALSE | |||
); | |||
ALTER TABLE poc_library_component OWNER TO is3_as; | |||
Note: apparently, Postgres does not like uppercases in column names. |
Revision as of 03:04, 26 November 2017
Internal
Database
List Databases
psql -l
or
SELECT datname FROM pg_database;
Create a Database
createdb <dbname>
or
CREATE DATABASE
Drop a Database
DROP DATABASE
Users
List Users
psql \du
Tablespace
List Tablespaces
psql \db
Tables
List Tables
psql \dt
Create a Table
CREATE TABLE poc_library_component ( "id" integer NOT NULL, "name" text, "desc" text, CONSTRAINT poc_library_component_pk PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); ALTER TABLE poc_library_component OWNER TO is3_as;
Note: apparently, Postgres does not like uppercases in column names.