Databases: SQL Dr Andy Evans. SQL (Structured Query Language) ISO Standard for database management. Allows creation, alteration, and querying of databases.

Slides:



Advertisements
Similar presentations
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Advertisements

SQL Rohit Khokher.
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Introduction to Structured Query Language (SQL)
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
19-Jun-15 SQL. SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell” is the only correct.
Using SQL to create tables Ways of using Databases.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Database Management System LICT 3011 Eyad H. Elshami.
1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
Programming for Geographical Information Analysis: Advanced Skills Lecture 5: Database connectivity Dr Andy Evans.
Chapter 7: SQL, the Structured Query Language Soid Quintero & Ervi Bongso CS157B.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Structured Query Language Chris Nelson CS 157B Spring 2008.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
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.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Features of SQL SQL is an English-like language . It uses words such as select , insert , delete as part of its commend set. SQL is an a non-procedural.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
CMPT 258 Database Systems The Relationship Model (Chapter 3)
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
Standard language for querying and manipulating data Structured Query Language Many standards out there: ANSI SQL, SQL92 (a.k.a. SQL2), SQL99 (a.k.a. SQL3),
SQL, the Structured Query Language
SQL Query Getting to the data ……..
Structured Query Language
SQL: Schema Definition and Constraints Chapter 6 week 6
Introduction to Structured Query Language(SQL)
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Introduction To Structured Query Language (SQL)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Database systems Lecture 3 – SQL + CRUD
SQL Queries Chapter No 3.
SQL Python and Databases ORMs
Instructor: SAMIA ARSHAD
SQL (Structured Query Language)
Presentation transcript:

Databases: SQL Dr Andy Evans

SQL (Structured Query Language) ISO Standard for database management. Allows creation, alteration, and querying of databases. Broadly divided into: Data Manipulation Language (DML) : data operations Data Definition Language (DDL) : table & database operations Often not case-sensitive, but better to assume it is. Commands therefore usually written UPPERCASE. Some databases require a semi-colon at the end of lines.

Creating Tables CREATE TABLE tableName ( col1Name type, col2Name type ) List of datatypes at: CREATE TABLE Results ( Address varchar(255), Burglaries int ) Note the need to define String max size.

SELECT command SELECT column, column FROM tables in database WHERE conditions ORDER BY things to ordered on SELECT Addresses FROM crimeTab WHERE crimeType = burglary ORDER BY city

Wildcards * : All (objects) % : Zero or more characters (in a string) _ : One character [chars] : Any character listed [^charlist] or [!charlist] : Any character not listed E.g. Select all names with an a,b, or c somewhere in them: SELECT * FROM Tab1 WHERE name LIKE '%[abc]%'

Case sensitivity If you need to check without case sensitivity you can force the datatype into a case insensitive character set first: WHERE name = ‘bob' COLLATE SQL_Latin1_General_CP1_CI_AS Alternatively, if you want to force case sensitivity: WHERE name = ‘Bob' COLLATE SQL_Latin1_General_CP1_CS_AS

Counting Can include count columns. Count all records: COUNT (*) AS colForAnswers Count all records in a column: COUNT (column) AS colForAnswers Count distinct values: COUNT(DISTINCT columnName) AS colForAnswers SELECT crimeType, COUNT(DISTINCT Address) AS HousesAffected FROM crimes

Joining tables Primary key columns: Each value is unique to only one row. We can join two tables if one has a primary key column which is used in rows in the other: SELECT Table1.columnA, Table2.columnB FROM Table1 JOIN Table2 ON Table1.P_Key=Table2.id Table1 P_keycolumnA 1A 2B 3C Table2 P_keycolumnBid aHH1 bGG1 cYY3 AHH AGG CYY

Altering data Two examples using UPDATE: UPDATE Table1 SET column1 = ‘string’ WHERE column2 = 1 UPDATE Table1 SET column1 = column2 WHERE column3 = 1

SQL Introductory tutorials: