Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha

Slides:



Advertisements
Similar presentations
COP4710 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen TA: Haiman Tian.
Advertisements

SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
COP4710 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen Ta: Hsin-Yu Ha.
1 CSE 480: Database Systems Lecture 9: SQL-DDL Reference: Read Chapter of the textbook.
Oracle Data Definition Language (DDL)
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
DBMS Spring 2014 Database Integrity Sources: Security in Computing, Pfleeger and Pfleeger, Prentice Hall, 2003 Lecture Slides, CSE6243, MSU, Rayford B.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
CREATE TABLE CREATE TABLE statement is used for creating relations Each column is described with three parts: column name, data type, and optional constraints.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
COP5725 D ATABASE M ANAGEMENT C ONNECT TO P OSTGRE SQL SEVER VIA PG A DMIN Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Managing Database With Oracle Replacement for Ch10 COP 4708.
CREATE TABLE ARTIST ( ArtistID int NOT NULL IDENTITY (1,1), Namechar(25) NOT NULL, TEXT ERROR Nationality char (30) NULL, Birthdate numeric (4,0) NULL,
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Constraints Review. What is a constraint? Unique – forbids duplicate values Referencial – Foreign key Check Constraint – sets restrictions on data added.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
Oracle sql Online Training By SMART MIND ONLINE TRAINING Website:
Marketing Analytics: Database Query with MySQL Disclaimer: All logos, photos, etc. used in this presentation are the property of their respective copyright.
CS320 Web and Internet Programming SQL and MySQL
Insert, Update and the rest…
© 2016, Mike Murach & Associates, Inc.
COP5725 Database Management Connect to PostgreSQL sever via pgAdmin
MYSQL and WAMP On LocalHost
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Order Database – ER Diagram
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Chapter 8 Working with Databases and MySQL
COP5725 DATABASE MANAGEMENT POSTGRESQL TUTORIAL
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
CS4222 Principles of Database System
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
2016, Fall Pusan National University Taehoon Kim
What is a Database? A collection of data organized in a manner that allows access, retrieval, and use of that data.
אבטחת נתונים בסביבת SQL Data Security
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
CS122 Using Relational Databases and SQL
Database Management System
Session - 6 Sequence - 1 SQL: The Structured Query Language:
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
Chapter 2: Creating And Modifying Database Tables
Relational Database Design
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Data Definition Language
Blog: Slides:
Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha
COP4710 Database Management Connect to PostgreSQL sever via pgAdmin
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
Instructor: Samia arshad
Session - 6 Sequence - 1 SQL: The Structured Query Language:
CS122 Using Relational Databases and SQL
ETL Processing Mechanics of ETL.
CS122 Using Relational Databases and SQL
Data Base.
Presentation transcript:

Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha COP4710 Information storage & retrieval Connect to PostgreSQL server via pgAdmin Prepared for Prof. JAI NAVLAKHA By Hsin-Yu Ha

Procedure outline Download pgAdmin from http://www.pgadmin.org/ Install pgAdmin Connect to PostgreSQL through pgAdmin Start creating your own database. May 2016: Download v1.22.1 (not v1.12.3 as stated in Slide 4)

Download pgAdmin (1) Go to PgAdmin Website Click download

Download pgAdmin (2) Select the latest reliable version v1.12.3

Download pgAdmin (3)

Download pgAdmin (4) Download pgadmin3-1.12.3.zip and extracted.

Install pgAdmin (1) After extracting the zip file “pgadmin3-1.12.3.zip” , execute the file pgadmin3.msi and start the installation process.

Install pgAdmin (2)

Install pgAdmin (3)

Install pgAdmin (4) The installation is successfully finished

Connect to PostgreSQL (1) Open pgAdmin and add a connection to a server

Connect to PostgreSQL (2) Name for server connection: cop4710 Host server: cop4710-postgresql.cs.fiu.edu Database Name: fall17_FIUusername Username: fall17_FIUusername Password: Panther ID

Create a database (1) Create table Primary key and Foreign key Constraints: NOT NULL UNIQUE CHECK Boolean expression For instance CHECK (price>0) (4) PRIMARY KEY (5) FOREIGN KEY CREATE TABLE products ( product_no integer PRIMARY KEY, name text NOT NULL, price numeric ); Primary key and Foreign key CREATE TABLE order_items ( product_no integer REFERENCES products, order_id integer REFERENCES orders, quantity integer, PRIMARY KEY (product_no, order_id), CONSTRAINT cq CHECK (quantity > 5) );

Create a database (2) Foreign Key CREATE TABLE other_table ( c1 integer PRIMARY KEY, c2 integer ); CREATE TABLE t1 ( a integer PRIMARY KEY, b integer, c integer, FOREIGN KEY (b, c) REFERENCES other_table (c1, c2) );

Create a database (3) CREATE TABLE products ( product_no integer PRIMARY KEY, name text, price numeric ); CREATE TABLE orders( order_id integer PRIMARY KEY, shipping_address text, … CREATE TABLE order_items ( product_no integer REFERENCES products ON DELETE RESTRICT, order_id integer REFERENCES orders ON DELETE CASCADE, quantity integer, PRIMARY KEY (product_no, order_id)

Create a database (4) Insert Data INSERT INTO products (product_no , name ,price) VALUES (1,'cheese',5); INSERT INTO products VALUES (1,'cheese',5), (2,’cake’,10) ;

Create a database (5) Import Data Export Data COPY country FROM '/usr1/proj/bray/sql/country_data.csv' WITH DELIMITER ',' ; COPY country TO '/sql/country_data.csv' WITH DELIMITER '|';

Create a database (6) ALTER Table Add columns Remove columns Add constraints ALTER TABLE products ADD COLUMN description text; ALTER TABLE products DROP COLUMN description; ALTER TABLE products ADD CONSTRAINT namecheck CHECK (name <> ''); ALTER TABLE products ADD CONSTRAINT some_name UNIQUE (product_no); ALTER TABLE products ADD FOREIGN KEY (product_group_id) REFERENCES product_groups; ALTER TABLE products ALTER COLUMN product_no SET NOT NULL;

Create a database (7) ALTER Table Remove constraints Change column data types Rename columns Rename tables ALTER TABLE products DROP CONSTRAINT some_name; ALTER TABLE products ALTER COLUMN product_no DROP NOT NULL; ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2); ALTER TABLE products RENAME COLUMN product_no TO product_number; ALTER TABLE products RENAME TO items;

Create a database (8) Delete Data DELETE FROM products WHERE price = 10; DELETE FROM products