EX NO 4
EX NO 4
NO:4
postgres=# create database rentaldb;
CREATE DATABASE
postgres=# \connect rentaldb;
You are now connected to database "rentaldb" as user "postgres".
rentaldb=# create table branch(branch_no varchar(18) primary key,street
varchar(18) not null,city varchar(18) not null,postcode varchar(18));
CREATE TABLE
rentaldb=# insert into branch(branch_no,street,city,postcode) values('b005',
'23,deer st','london','sw14eh');
INSERT 0 1
rentaldb=# insert into branch(branch_no,street,city,postcode) values('b005',
'23,deer st','london','sw14eh');
ERROR: duplicate key value violates unique constraint "branch_pkey"
DETAIL: Key (branch_no)=(b005) already exists.
rentaldb=# \d+ branch
Table "public.branch"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
-----------+-----------------------+-----------+----------+---------+----------+
-------------+--------------+-------------
branch_no | character varying(18) | | not null | | extended |
| |
street | character varying(18) | | not null | | extended |
| |
city | character varying(18) | | not null | | extended |
| |
postcode | character varying(18) | | | | extended |
| |
Indexes:
"branch_pkey" PRIMARY KEY, btree (branch_no)
Access method: heap
| branch_no
-------------+--------+------+----------+------+-------+------+----------
+----------
+-----------
(0 rows)
rentaldb=# \d+;
List of relations
Schema | Name | Type | Owner | Persistence | Access method |
Size | Description
--------+-------------------+-------+----------+-------------+---------------+-
-----------+-------------
public | branch | table | postgres | permanent | heap |
8192 bytes |
public | client | table | postgres | permanent | heap |
8192 bytes |
public | private_owner | table | postgres | permanent | heap |
8192 bytes |
public | property_for_rent | table | postgres | permanent | heap |
8192 bytes |
public | staff | table | postgres | permanent | heap |
8192 bytes |
public | viewing | table | postgres | permanent | heap |
16 kB |
(6 rows)