Beginning SQL Tutorial Author Jay Mussan-Levy. What is SQL?  Structured Query Language  Communicate with databases  Used to created and edit databases.

Slides:



Advertisements
Similar presentations
Session 2Introduction to Database Technology Data Types and Table Creation.
Advertisements

Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Database Basics I101 Summer 2006 Copyright 2004, Matt Hottell.
Chapter 8 Special-Purpose Languages. SQL SQL stands for "Structured Query Language". Allows the user to pose complex questions of a database. It also.
Introduction to Structured Query Language (SQL)
This course has taken from This unique introductory SQL tutorial not only provides easy-to-understand SQL instructions, but it allows.
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.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
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”
Introduction to Structured Query Language (SQL)
Introduction to SQL  SQL or sequel  It is a standardised language with thousands of pages in the standard  It can be in database system through GUI,
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Eagle rock information systems 199 So Los Robles, Suite 860, Pasadena, CA USA SQL Overview Introduction to SQL for.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Database: SQL and MySQL
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 What is database 2? What is normalization? What is SQL? What is transaction?
SQL (DDL & DML Commands)
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
1 Information Retrieval and Use (IRU) CE An Introduction To SQL Part 1.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
Visual Programing SQL Overview Section 1.
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,
Information Technology Structured Query Language Grade11.
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
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.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
Insert, Update and the rest…
MIS2502: Data Analytics SQL – Putting Information Into a Database
ISC440: Web Programming 2 Server-side Scripting PHP 3
STRUCTURED QUERY LANGUAGE
SQL Tutorial.
Creating Tables & Inserting Values Using SQL
MIS2502: Data Analytics SQL – Putting Information Into a Database
Lecture 3 Finishing SQL
Structured Query Language
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
The University of Akron College of Applied Science & Technology Dept
Presentation transcript:

Beginning SQL Tutorial Author Jay Mussan-Levy

What is SQL?  Structured Query Language  Communicate with databases  Used to created and edit databases.  Also used to create queries, forms, and reports

Table Basics  A Table is an object  Database data is stored in Tables  Each table has a unique name  Columns have various attributes, such as column name and data type  Rows contain records or data for the columns

Weather Sample Table CityStateHighLow PhoenixArizona10590 TusconArizona10192 FlagstaffArizona8869 San DiegoCalifornia7760 AlbuquerqueNew Mexico8060

Selecting Data The Select statement is used to get data which matches the specified criteria. Here is the basic syntax: ex) select “columnname1”, “columnname2” from “tablename” where “condition”

Conditions Used In Where Clause = equals > greater than < less than >= greater than or equal to <= less than or equal to <> not equal to

Like Used to make complex searching easy. If you are trying to find all people’s names which begin with E for example: ex) select firstname from employee where firstname LIKE 'E%';

Selecting Exercise Go to Scroll to the bottom of the page. Do exercises 2, 4, and 6. The tables you need are in your handout packet

Creating Tables The statement to use is create table Here is the syntax: create table “tablename” (“columnname”, “datatype”, “columnname2”, “datatype”, “columnname3”, “datatype”);

Creating Tables cont’d Here is a real example: create table employee (first varchar(15), last varchar(20), age number(3), address varchar(30), city varchar(20), state varchar(20));

Creating Tables - Steps 1. Use the command create table 2. Follow it with the correct table name 3. Put a parenthesis and type in the first column name 4. Follow it with the variable type (we will list them in a minute) then a comma 5. Continue the previous two steps until you have all your columns accounted for 6. Then put a parenthesis to close the columnname section and add a ; after it

Creating Tables - Rules  Table and column names must start with a letter  They can not exceed 30 characters  They can not be key words such as create, insert, select, etc.

Creating Tables – Variables  If you took algebra then y=2x might be familiar. y and x are unknown information, which is a variable.  Now a string is a bunch of letters and numbers  A number is a bunch of numbers  A data type determines what a variable can hold, i.e. strings or numbers

Creating Tables – Data Types  char(size) - all column entries must be = size, which you specify at the beginning, if size = 10 then you must have ten characters  varchar(size) - all column entries must be less than or equal to whatever size is, if size is 10, then the string must be between 1-10 charcters

Creating Tables – Data Types cont’d  number(size) - a number value that can not exceed, size columns, for example if you have size = 10, then you can only have 10 different digit places, like 1,000,000,000  date - date value  number(size,d) - This works the same as the regular number except d represents # of columns after the decimal.

Creating Tables - Constraints A constraint is a rule. Some examples constraints are: unique - no two entries will be the same not null - no entry can be blank **primary key - unique identification of each row** primary keys will be very important to you as your knowledge of databases progresses

Creating Table Exercise Go to Do the exercise listed under the heading Create Table Exercise

Inserting Information into Tables To insert into tables you need only use the keyword insert. Here is the syntax: insert into "tablename" (“first_column”,..., “last_column”) values (“first_value”,...,“last value”);

Inserting Information into Tables Here is a practical example: insert into employees (first, last, age, address, city, state) values ( 'Luke', 'Duke', 45, '2130 Boars Nest', 'Hazard Co', 'Georgia');

Inserting Information into Tables Steps **All strings should be enclosed by single quotes: 'string'** 1. Use the keyword "insert into" followed by the tablename 2. Then on the next line, in parenthesis, list all the columns you are inserting values for. 3. Then on the line after, type values, then in parenthesis, put the values in the same order as the columns they belong to

Inserting Information Exercise Go to All the employees you need to insert are listed in your handout Do exercises 3, 4, 5, and 8 under the heading: Insert statement exercises

Updating Records To update records use the "update" statement. Here is the syntax: update “tablename” set “columnname” = “newvalue”, “nextcolumn” = “newvalue2”,... where “columnname” OPERATOR “value” and|or “columnname2 OPERATOR “value”

Updating Records cont’d Here are some practical examples: ex) update phone_book set area_code = 623 where prefix = 979; This changes the area code all numbers beginning with 979 to 623

Updating Records cont’d update phone_book set last_name = 'Smith', prefix=555, sufix=9292 where last_name = 'Jones'; This changes everyone whose last name is Jones to Smith and their number to

Updating Records Exercise Go to Do Exercises 1, 2, 3, 5 under the heading: Update statement exercises

Deleting Records Here is the syntax: delete from “tablename” where “columnname” OPERATOR “value” and|or “columnname2” OPERATOR “value”

Deleting Records Examples ex) delete from employees; deletes all records from that table ex) delete from employee where lastname='May'; deletes all records for people whose last name is May ex) delete from employee where firstname='Mike' or firstname='Eric'; deletes all records for anyone whose first name is Mike or Eric

Deleting Records Exercise Go to Do all the exercises under the heading: Delete statement exercises

Deleting Tables Use the drop command drop table "tablename"; drop table employees; Bye Bye Table, Hello Corporate Espoinage =)

Deleting Table Exercise Go to Do the Exercise under the heading: Drop Table exercises

Further SQL Information Congratulations, you have just learned the basics of SQL!! However, there are still a few more advanced concepts that you should learn before you can say your good: Querying, Reports, and Forms If you have any questions me at