Pavel Titenkov © SQL. Pavel Titenkov © Общий обзор англ. Structured Query Language — «язык структурированных запросов»англ. Это наиболее часто используемый.

Slides:



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

CIT 613: Relational Database Development using SQL Introduction to SQL.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
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”
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Brad Lloyd & Michelle Zukowski 1 Design and Implementation CIS 400 Final Project Dr. Bruce Maxim SQL.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
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.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Working with Tables: Data Management and Retrieval Dr. Bernard Chen Ph.D. University of Central Arkansas.
SQL Training SQL Statements – Part 1. Confidential & Proprietary Copyright © 2009 Cardinal Directions, Inc. Lesson Objectives Explain the role of SQL.
Concepts of Database Management Seventh Edition
Introduction to SQL Steve Perry
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.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
1 Working with MS SQL Server Textbook Chapter 14.
© 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.
Introduction to MySQL Lab no. 10 Advance Database Management System.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
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 by Example By convention SQL keywords are written in uppercase. SELECT * FROM Books –This query returns all rows in the Books table. –SQL statements.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
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.
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.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
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,
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
SQL has several parts: Major ones: DDL – Data Definition Language {Defining, Deleting, Modifying relation schemas} DML – Data Manipulation Language {Inserting,
CIT 613: Relational Database Development using SQL Introduction to SQL DeSiaMorePowered by DeSiaMore 1.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
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.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
1 Section 10 - Embedded SQL u Many computer languages allow you to embed SQL statements within the code (e.g. COBOL, PowerBuilder, C++, PL/SQL, etc.) u.
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.
Programming Constructs
CS SQL.
CS 3630 Database Design and Implementation
Chapter 5 Introduction to SQL.
SQL and SQL*Plus Interaction
Insert, Update and the rest…
Introduction to Oracle9i: SQL
Design and Implementation
ORACLE SQL Developer & SQLPLUS Statements
SQL OVERVIEW DEFINING A SCHEMA
Design and Implementation
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Structured Query Language Path from Unorganized to Organized….
DATABASE Purpose of database
Presentation transcript:

Pavel Titenkov © SQL

Pavel Titenkov © Общий обзор англ. Structured Query Language — «язык структурированных запросов»англ. Это наиболее часто используемый язык для работы с БДЭто наиболее часто используемый язык для работы с БД SQL работает с множеством языков 4glSQL работает с множеством языков 4gl SQL

Pavel Titenkov © Используется для: Data ManipulationData Manipulation Data DefinitionData Definition Data AdministrationData Administration All are expressed as an SQL statement or command.All are expressed as an SQL statement or command. SQL

Pavel Titenkov © SQL Requirements SQL Must be embedded in a programming languageSQL Must be embedded in a programming language SQL is a free form language so there is no limit to the the number of words per line or fixed line break.SQL is a free form language so there is no limit to the the number of words per line or fixed line break. Syntax statements, words or phrases are always in lower case; keywords are in uppercase.Syntax statements, words or phrases are always in lower case; keywords are in uppercase. SQL Not all versions are case sensitive!

Pavel Titenkov © SQL is a Relational Database каждый элемент таблицы — один элемент данных все ячейки в столбце таблицы однородные, то есть все элементы в столбце имеют одинаковый тип (числовой, символьный и т. д.) каждый столбец имеет уникальное имя одинаковые строки в таблице отсутствуют порядок следования строк и столбцов может быть произвольным Реляционная модель ориентирована на организацию данных в виде двумерных таблиц. Каждая реляционная таблица представляет собой двумерный массив и обладает следующими свойствами:

Pavel Titenkov © Design Операторы SQL делятся на: операторы определения данных (Data Definition Language, DDL)DDL операторы манипуляции данными (Data Manipulation Language, DML)DML операторы определения доступа к данным (Data Control Language, DCL)DCL SQL

Pavel Titenkov © Rows describe the Occurrence of an Entity Table Design SQL NameAddress Jane Doe123 Main Street John Smith456 Second Street Mary Poe789 Third Ave Columns describe one characteristic of the entity

Pavel Titenkov © Data Retrieval (Queries) Queries search the database, fetch info, and display it. This is done using the keywordQueries search the database, fetch info, and display it. This is done using the keyword SELECT SELECT * FROM publishers pub_idpub_nameaddressstate 0736New Age Books1 1 st StreetMA 0987Binnet & Hardley2 2 nd StreetDC 1120Algodata Infosys3 3 rd StreetCA The * Operator asks for every column in the table.The * Operator asks for every column in the table.

Pavel Titenkov © Data Retrieval (Queries) Queries can be more specific with a few more linesQueries can be more specific with a few more lines pub_idpub_nameaddressstate 0736New Age Books1 1 st StreetMA 0987Binnet & Hardley2 2 nd StreetDC 1120Algodata Infosys3 3 rd StreetCA Only publishers in CA are displayedOnly publishers in CA are displayed SELECT * from publishers where state = ‘CA’

Pavel Titenkov © Data Input Putting data into a table is accomplished using the keywordPutting data into a table is accomplished using the keyword INSERT pub_idpub_nameaddressstate 0736New Age Books1 1 st StreetMA 0987Binnet & Hardley2 2 nd StreetDC 1120Algodata Infosys3 3 rd StreetCA Table is updated with new informationTable is updated with new information INSERT INTO publishers VALUES (‘0010’, ‘pragmatics’, ‘4 4th Ln’, ‘chicago’, ‘il’) pub_idpub_nameaddressstate 0010Pragmatics4 4 th LnIL 0736New Age Books1 1 st StreetMA 0987Binnet & Hardley2 2 nd StreetDC 1120Algodata Infosys3 3 rd StreetCA Keyword Variable

Pavel Titenkov © pub_idpub_nameaddressstate 0010Pragmatics4 4 th LnIL 0736New Age Books1 1 st StreetMA 0987Binnet & Hardley2 2 nd StreetDC 1120Algodata Infosys3 3 rd StreetCA Types of Tables User Tables: contain information that is the database management systemUser Tables: contain information that is the database management system System Tables: contain the database description, kept up to date by DBMS itselfSystem Tables: contain the database description, kept up to date by DBMS itself There are two types of tables which make up a relational database in SQL RelationTable TupleRow AttributeColumn

Pavel Titenkov © Using SQL SQL statements can be embedded into a program (cgi or perl script, Visual Basic, MS Access) OR OR SQL Database SQL statements can be entered directly at the command prompt of the SQL software being used (such as mySQL)

Pavel Titenkov © Using SQL To begin, you must first CREATE a database using the following SQL statement: CREATE DATABASE database_name Depending on the version of SQL being used the following statement is needed to begin using the database: USE database_name

Pavel Titenkov © Using SQL To create a table in the current database, use the CREATE TABLE keyword CREATE TABLE authors (auth_id int(9) not null, auth_name char(40) not null) auth_idauth_name (9 digit int)(40 char string)

Pavel Titenkov © Using SQL To insert data in the current table, use the keyword INSERT INTO auth_idauth_name Then issue the statement SELECT * FROM authors INSERT INTO authors values(‘ ’, ‘John Smith’) John Smith

Pavel Titenkov © Using SQL SELECT auth_name, auth_city FROM publishers auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI auth_nameauth_city Jane DoeDearborn John SmithTaylor If you only want to display the author’s name and city from the following table:

Pavel Titenkov © Using SQL DELETE from authors WHERE auth_name=‘John Smith’ auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI To delete data from a table, use the DELETE statement:

Pavel Titenkov © Using SQL UPDATE authors SET auth_name=‘hello’ auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI To Update information in a database use the UPDATE keyword Hello Sets all auth_name fields to hello

Pavel Titenkov © Using SQL ALTER TABLE authors ADD birth_date datetime null auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI To change a table in a database use ALTER TABLE. ADD adds a characteristic. ADD puts a new column in the table called birth_date birth_date.. TypeInitializer

Pavel Titenkov © Using SQL ALTER TABLE authors DROP birth_date auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI To delete a column or row, use the keyword DROP DROP removed the birth_date characteristic from the table auth_state..

Pavel Titenkov © Using SQL DROP DATABASE authors auth_idauth_nameauth_cityauth_state Jane DoeDearbornMI John SmithTaylorMI The DROP statement is also used to delete an entire database. DROP removed the database and returned the memory to system

Pavel Titenkov © Conclusion SQL is a versatile language that can integrate with numerous 4GL languages and applications SQL simplifies data manipulation by reducing the amount of code required. More reliable than creating a database using files with linked-list implementation

Pavel Titenkov © References “The Practical SQL Handbook”, Third Edition, Bowman.