Introduction to SQL
A Guide to Understanding and Using
SQL
Introduction to SQL
• SQL is a standard language for accessing and
manipulating databases.
What is SQL?
• SQL stands for Structured Query Language.
• SQL lets you access and manipulate databases.
• SQL became a standard of the ANSI in 1986,
and ISO in 1987.
What Can SQL Do?
• SQL can execute queries against a database.
• SQL can retrieve data from a database.
• SQL can insert, update, and delete records in a
database.
• SQL can create databases, tables, views, and
stored procedures.
• SQL can set permissions on tables,
procedures, and views.
SQL is a Standard - BUT...
• SQL is an ANSI/ISO standard, but there are
different versions.
• To comply with ANSI, major commands
(SELECT, UPDATE, DELETE, etc.) are supported
similarly.
• Most SQL database programs have proprietary
extensions in addition to the standard.
Using SQL in Your Website
• To build a website showing data from a
database, you need:
• - An RDBMS database program (e.g., MS
Access, SQL Server, MySQL).
• - A server-side scripting language (e.g., PHP,
ASP).
• - SQL to retrieve data.
• - HTML/CSS to style the page.
RDBMS
• RDBMS stands for Relational Database
Management System.
• RDBMS is the basis for SQL and modern
database systems (MySQL, SQL Server, etc.).
• Data in RDBMS is stored in database objects
called tables.
• A table is a collection of related data entries
consisting of columns and rows.
Tables, Fields, and Records
• A field is a column designed to maintain
specific information (e.g., CustomerID).
• A record (row) is each individual entry in a
table.
• Columns contain all information associated
with a specific field.
SQL Syntax
SQL Statements
• Most of the actions you need to perform on a
database are done with SQL statements.
• SQL statements consist of keywords that are
easy to understand.
• The following SQL statement returns all records
from a table named "Customers":
Example
• Select all records from the Customers table:
• SELECT * FROM Customers;
Keep in Mind That...
• SQL keywords are NOT case sensitive: select is the same as SELECT
• In this tutorial we will write all SQL keywords in upper-case.
Semicolon after SQL Statements?
• Some database systems require a semicolon at the end of each
SQL statement.
• Semicolon is the standard way to separate each SQL statement in
database systems that allow more than one SQL statement to be
executed in the same call to the server.
• In this tutorial, we will use semicolon at the end of each SQL
statement.
Some of The Most Important SQL Commands
•SELECT - extracts data from a database
•UPDATE - updates data in a database
•DELETE - deletes data from a database
•INSERT INTO - inserts new data into a
database
•CREATE DATABASE - creates a new database
•ALTER DATABASE - modifies a database
•CREATE TABLE - creates a new table
•ALTER TABLE - modifies a table
•DROP TABLE - deletes a table
•CREATE INDEX - creates an index (search key)
•DROP INDEX - deletes an index
slides about :  Introduction_to_SQL.pptx

slides about : Introduction_to_SQL.pptx

  • 1.
    Introduction to SQL AGuide to Understanding and Using SQL
  • 2.
    Introduction to SQL •SQL is a standard language for accessing and manipulating databases.
  • 3.
    What is SQL? •SQL stands for Structured Query Language. • SQL lets you access and manipulate databases. • SQL became a standard of the ANSI in 1986, and ISO in 1987.
  • 4.
    What Can SQLDo? • SQL can execute queries against a database. • SQL can retrieve data from a database. • SQL can insert, update, and delete records in a database. • SQL can create databases, tables, views, and stored procedures. • SQL can set permissions on tables, procedures, and views.
  • 5.
    SQL is aStandard - BUT... • SQL is an ANSI/ISO standard, but there are different versions. • To comply with ANSI, major commands (SELECT, UPDATE, DELETE, etc.) are supported similarly. • Most SQL database programs have proprietary extensions in addition to the standard.
  • 6.
    Using SQL inYour Website • To build a website showing data from a database, you need: • - An RDBMS database program (e.g., MS Access, SQL Server, MySQL). • - A server-side scripting language (e.g., PHP, ASP). • - SQL to retrieve data. • - HTML/CSS to style the page.
  • 7.
    RDBMS • RDBMS standsfor Relational Database Management System. • RDBMS is the basis for SQL and modern database systems (MySQL, SQL Server, etc.). • Data in RDBMS is stored in database objects called tables. • A table is a collection of related data entries consisting of columns and rows.
  • 8.
    Tables, Fields, andRecords • A field is a column designed to maintain specific information (e.g., CustomerID). • A record (row) is each individual entry in a table. • Columns contain all information associated with a specific field.
  • 9.
    SQL Syntax SQL Statements •Most of the actions you need to perform on a database are done with SQL statements. • SQL statements consist of keywords that are easy to understand. • The following SQL statement returns all records from a table named "Customers": Example • Select all records from the Customers table: • SELECT * FROM Customers;
  • 10.
    Keep in MindThat... • SQL keywords are NOT case sensitive: select is the same as SELECT • In this tutorial we will write all SQL keywords in upper-case. Semicolon after SQL Statements? • Some database systems require a semicolon at the end of each SQL statement. • Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. • In this tutorial, we will use semicolon at the end of each SQL statement.
  • 11.
    Some of TheMost Important SQL Commands •SELECT - extracts data from a database •UPDATE - updates data in a database •DELETE - deletes data from a database •INSERT INTO - inserts new data into a database •CREATE DATABASE - creates a new database •ALTER DATABASE - modifies a database •CREATE TABLE - creates a new table •ALTER TABLE - modifies a table •DROP TABLE - deletes a table •CREATE INDEX - creates an index (search key) •DROP INDEX - deletes an index