0% found this document useful (0 votes)
6 views2 pages

Postgres SQL DDL and DML Guide

The document provides an overview of PostgreSQL commands including DDL (create, alter, drop) and DML (insert, update). It includes examples of creating and modifying tables, inserting data, and querying results. Additionally, it discusses data types and the concept of primary keys in table design.

Uploaded by

rishavdhania30
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Postgres SQL DDL and DML Guide

The document provides an overview of PostgreSQL commands including DDL (create, alter, drop) and DML (insert, update). It includes examples of creating and modifying tables, inserting data, and querying results. Additionally, it discusses data types and the concept of primary keys in table design.

Uploaded by

rishavdhania30
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Postgres SQL

1. DDL :- create, alter, truncate, drop


2. DML :- insert, update,

 create database Rishav31;


create table student(
rollno int,
name varchar,
course varchar,
fees decimal(10,2)
);
Note- if existing table have unique identity then we make it primary key

 drop table student;

 create table marks(


rollno int not null primary key,
name varchar,
java int,
pyrthon int,
dsa int,
sql int
);

 insert into marks values(1001,'amit',50,60,58,78),


(1002,'sumit',18,56,78,45),
(1003,'pankaj',55,78,36,59),
(1004,'kamal',69,77,45,89);

 select *from marks;

 select java+pyrthon+dsa+sql as total from marks;

 alter table marks add column totalmarks int,add column per decimal(2,2);
Postgres SQL

 alter table marks add column totalmarks int,add column per decimal(5,2);

note:- Unique can be null it can be a primary key.

Note:-
Smallserial 2byte 1 to 65536
Serial 4byte 1 to 2,147,483,147
Bigserial 8byte

You might also like