PostGres SQL

• Presented by :

Chandan , Markandey Amit , Kiran Harshada , Prachi

Introduction
• What is „ PostGres „ ? • An overview on Classes Inferitance Arrays Geometric Types

• A query can reference to either all instances of a class or all instances of a class plus all of its descendents. .Inheritance • A class can inherit from zero or more other classes. • The inheritance hierarchy is a directed acyclic graph.

) • CREATE TABLE cities ( name text .Inheritance ( Cont. • CREATE TABLE capitals ( state char10 ) INHERITS ( cities ) . . population int. altitude int ) .

Arrays • Valid for variable-length & fixed-length multi-dimensional arrays. • CREATE TABLE sal_emp ( name text. pay int4[ ]. • Array with n elements start by array[1] and ends with array[n]. schedule text[ ][ ] ) . .

y1) .y).Geometric Types • Represent two dimensional spatial object. Rectangular Box etc. Circle .r> Circle . Infinite Line . • Points . (x2.y) Point in Space ( (x1.y2)) Line <(x. • PostGres geometric type : (x.

Create a new postgres user • Synopsis : createuser [ options] [username] • Inputs : . Host specifies the hostname of machine on which postmaster is running.CreateUser • Name : createuser . .h : host.

. ) .CreateUser ( Cont. username : Specifies the name of the postgres user to be created . Echo the queries that createdb generates and sends to the backend.e : echo .This name must be unique among all postgres users.

) • Outputs : CREATE USER All is well createuser : creation of user “username” failed. Something went wrong .CreateUser ( Cont . The user was not created. .

. ) • Description : • createuser creates a new PostGres user. Only users with usesuper set in the pg_shadow class can create new PostGres users.CreateUser ( Cont.

) • Usage : To create user joe on the default database server.CreateUser ( Cont. $ createuser joe Is the new user allowed to create databases? n CREATE USER .

h : host .Host specifies the host name of machine on which postmaster is running.DropUser • Name : dropuser .Drops (removes) a postgres user. • Synopsis : dropuser [ options] [username] • Inputs : . .

DropUser ( Cont. Echo the queries that createdb generates and sends to the backend.e : echo . ) • . . This name must exist in the postgres installation. • Username : Specifies the name of the postgres user to be removed.

DropUser ( Cont. The user was not removed. . Dropuser : deletion of user “username” failed. Something went wrong. ) • Output : DROP USER All is well.

Only users with usesuper set in the pg_shadow class can destroy postgres users. ) • Description : • dropuser removes an existing user and the databases which that user owned .DropUser ( Cont. .

$ dropuser joe DROP USER .DropUser ( Cont. ) • Usage : to remove user joe from the default database server.

• Destroydb . • Droplang : Remove a programming language from a postgres database. • Createlang : Add a new programming language to a postgres database.Remove an existing PostGres database .Applications • Createdb .Create a new PostGres database. .

Pg_Dump • Name : pg_dump . • Synopsis : pg_dump [options] [dbname] .Extract a PostGres database into a script file.

Cont. • -c : Clean schema prior to create . • -a : Dump out only the data. no schema. • Inputs : • dbname : Specifies the name of the database to be extracted. Dbname defaults to the value of the USER environment variable.

• Output pg_dump will create a file or write to stdout • Description pg_dump is a utility for dumping out a postgres database into a script file containing query commands.Cont. .

aggregates and operators.Cont.pg_dump will produce the queries necessary to regenerate all user defined types .even on other machine and other architecture. • The script files are in text format and can be used to reconstruct database .tables.indices.functions. .

out .Cont. • Usage To dump a database of the same name as the user: $pg_dump > db.out To reload this database: $psql -e database < db.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.