PostgreSQL Create Table
$count++; if($count == 1) { #include "../mobilemenu.php"; } if ($count == 2) { include "../sharemediasubfolder.php"; } ?>
See, I am running cosmiclearn. As owner of cosmiclearn I want to create a table that can store planets.
So the requirement is as follows:
Table name: Planet
Attributes:
name: varchar(50) - So a string of upto 50 characters.
galaxyname: varchar(40) - A string of upto 40 characters.
numberOfMoons: int - An integer field representing number of moons.
weight: double - A double field representing weight.
creation: date - A Date field representing when the planet is created.
cosmos=# CREATE TABLE PLANET (NAME VARCHAR(50),GALAXYNAME VARCHAR(40),NUMBEROFMOONS INT,WEIGHT FLOAT, CREATION DATE);
CREATE TABLE
The above command will create a table in MySQL. Once created, we can use show tables command.
cosmos=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | planet | table | postgres
(1 row)
To see the metadata of the table we just created, we can use the \d+ command.
cosmos=# \d+ PLANET;
Table "public.planet"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------------+-----------------------+-----------+----------+---------+----------+--------------+-------------
name | character varying(50) | | | | extended | |
galaxyname | character varying(40) | | | | extended | |
numberofmoons | integer | | | | plain | |
weight | double precision | | | | plain | |
creation | date | | | | plain | |