An introduction to SQL 1/21/2014 – See chapter 2.3 and 6.1 PostgreSQL -

Slides:



Advertisements
Similar presentations
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Advertisements

Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
Introduction to Structured Query Language (SQL)
 Review HW #4  Answer questions about Microsoft Visio  Introduce SQL  Introduce SQL Server 2008 environment for programming SQL  Will meet in AB208.
Introduction to Structured Query Language (SQL)
MySQL and PHP By Trevor Adams.
Introduction to Structured Query Language (SQL)
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Chapter 4: Organizing and Manipulating the Data in Databases
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.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Database Lecture # 1 By Ubaid Ullah.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
ASP.NET Programming with C# and SQL Server First Edition
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Concepts of Database Management Seventh Edition
Database Technical Session By: Prof. Adarsh Patel.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
Python MySQL Database Access
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
© 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.
Guofeng Cao CyberInfrastructure and Geospatial Information Laboratory Department of Geography National Center for Supercomputing Applications (NCSA) University.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
MySQL Database Management Systems Universitas Muhammadiyah Surakarta Yogiek Indra Kurniawan.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
Oracle & SQL Introduction. Database Concepts Revision DB? DBMS? DB Application? Application Programs? DBS? Examples of DBS? Examples of DBMS? 2Oracle.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
DBMS_Week 3-4 DBMS. Three-Schema Architecture – Internal schema (one view) describes physical storage structures access paths, indexes used Typically.
Agenda for Class 2/20/2014 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
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.
1 A Very Brief Introduction to Relational Databases.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Introduction to Database Programming with Python Gary Stewart
Understanding Core Database Concepts Lesson 1. Objectives.
Fundamental of Database Systems
CS 3630 Database Design and Implementation
CS320 Web and Internet Programming SQL and MySQL
Advanced Accounting Information Systems
Oracle & SQL Introduction
CS1222 Using Relational Databases and SQL
Aqua Data Studio.
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
CS1222 Using Relational Databases and SQL
SQL Queries Chapter No 3.
CMPT 354: Database System I
CS1222 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Understanding Core Database Concepts
CS1222 Using Relational Databases and SQL
Presentation transcript:

An introduction to SQL 1/21/2014 – See chapter 2.3 and 6.1 PostgreSQL Acknowledgement – Thanks to Dr. Mayfield for the lab activity.

SQL Query language Divided into “clauses” each of which does a particular piece of work. Two kinds of languages DDL – Data Definition Language – Manipulates the database schema DML – Data Manipulation Language – Manipulates the database data

DDL (2.3) CREATE – Makes new database objects CREATE TABLE … CREATE USER … CREATE DATABASE … ALTER – Changes database objects ALTER TABLE …

DML – 6.1 SELECT – Read only query to examine data from the database. May be used in conjunction with update statements. UPDATE – Update existing data INSERT – Insert new rows DELETE – Delete existing rows

Important clauses SELECT – Chooses the individual fields (columns) from the database (not necessarily a particular table) FROM – Chooses which table(s) we are working with WHERE – Provides criteria for the selection

PostgreSQL Relational DBMS use SQL but each has their own dialects and supported features. PostgreSQL is: “PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.” (

Our server db.cs.jmu.edu Accessible from JMU networks only Hardware 2*12 Core Opteron 2.2 GHz 48 GB RAM (plus 48 GB swap) 6*275 GB Disks (1.5 TB free) Software Linux 3.8 (Ubuntu ) PostgreSQL 9.1

Additional server For those interested in exploring MySQL it is available on: daisy.cs.jmu.edu See me if you want an account.

Logging in From the command line: psql -h db.cs.jmu.edu -U username To change your password: \ password Your db account is separate from your JMU account! Do it now

Create a table using DDL CREATE TABLE movie ( id integer, title text, year integer, genres text, mpaa text, budget text ); White space does not matter but style dictates indentation for readability. Case does not matter for the keywords like CREATE and TABLE but convention has us capitalize them. Do it now!

Loading the db Choices – You can hand enter the data …. OR – You can load it from a file. Today we will load from a file.

Load the database Download About 1.4 MB Uncompress gunzip movies.csv.gz Now 3.8 MB With psql \copy movie FROM movies.csv WITH CSV HEADER; ANALYZE VERBOSE movie; 63,508 rows NOTE: \ is an escape which says to do this outside of psql

Basic psql commands General \? help on psql commands \h: help on SQL syntax \i execute commands from file \q: quit psql (or Ctrl-D) Browsing \d: list tables, views, etc \d NAME: describe table, NAME,/etc Important Ctrl-C cancels the current query Tab completion is your friend!

Your first DML query SELECT title -- what you want from the db FROM movie-- the table to operate on WHERE year = 2012;-- the criterion Use up/down arrows and page up/down g or G: go to first / last line / or ?: search forward / backward Press ‘h’ for help Press ‘q’ to quit

Explore Write another query that includes more than one field in the select and a different criterion. You can use AND and OR to combine criteria. Multiple fields are separated by commas in the SELECT statement.

Homework Download any data set from: Create the table Import the data into your database Write several queries exploring the data set. See HW03 in Canvas