This is in continuation of My last blog about Meta Commands in PostgreSQL. In last blog I have explained what a Meta command and how to list databases. In next few blogs we will explore few of Meta commands. Lets start exploring schemas.
The command we will explore here is:
2. CREATE TABLE
Once we are able to connect to our database using \c and connect to our schema using set search_path, we can list all tables of that particular schema using
We can also use CREATE TABLE statement to create a table. We will create a table writer which will hold few attributes of blog writer.
We will try
\dt again to see the updated list. We can see both the table name posts & writer. postgresblogs are the schema for both the table and postgres user is owner of them.
Since, we have created a table, we would like to see the structure of this table at any point of time. We can easily do that using help of \d
If we analyze the output, we can easily see that the output is informative. It is listing column name with it’s datatype and lengths (precision), character set information using collation and other info in default column of the output.
In next blog we will explore further commands which we can run in psql