This document provides an overview of the Database course titled "Database" (ITI131) taught by Prof. Taymoor Mohamed Nazmy in the Department of Computer Science at Ain Shams University in Cairo, Egypt. It introduces relational algebra and SQL, covering topics such as basic relational algebra operations like selection, projection, union, and Cartesian product. It also discusses SQL, including its history, different types of SQL statements, and how SQL can be used to retrieve and manipulate data from a database for use in web applications.
This presentation deals with the fundamentals of SQL, Installation and Database concepts. Presented by our team in Alphalogic Inc: https://www.alphalogicinc.com/
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis
Migration from one database engine to another one for existing applications is not a trivial task. There are a lot of technical challenges, including but not limited to database features, object/data types and different behavior. In this presentation we would like to talk about a customer PoC, with the goal to migrate as many databases from Oracle to MySQL as possible. This includes categorization of several hundred Oracle databases into migration classes, based on custom criteria, as well as tool development to support schema (DDL) conversion and data migration.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
This presentation deals with the fundamentals of SQL, Installation and Database concepts. Presented by our team in Alphalogic Inc: https://www.alphalogicinc.com/
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis
Migration from one database engine to another one for existing applications is not a trivial task. There are a lot of technical challenges, including but not limited to database features, object/data types and different behavior. In this presentation we would like to talk about a customer PoC, with the goal to migrate as many databases from Oracle to MySQL as possible. This includes categorization of several hundred Oracle databases into migration classes, based on custom criteria, as well as tool development to support schema (DDL) conversion and data migration.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
Database such as MySQL and SQL server are an integral part of business, hospital, banks and universities. Immensely, Every person who have of access computer or technology eventually work on to store data.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
PostgreSQL Tutorial For Beginners | EdurekaEdureka!
YouTube Link: https://youtu.be/-VO7YjQeG6Y
** MYSQL DBA Certification Training https://www.edureka.co/mysql-dba **
This Edureka PPT on PostgreSQL Tutorial For Beginners (blog: http://bit.ly/33GN7jQ) will help you learn PostgreSQL in depth. You will also learn how to install PostgreSQL on windows. The following topics will be covered in this session:
What is DBMS
What is SQL?
What is PostgreSQL?
Features of PostgreSQL
Install PostgreSQL
SQL Command Categories
DDL Commands
ER Diagram
Entity & Attributes
Keys in Database
Constraints in Database
Normalization
DML Commands
Operators
Nested Queries
Set Operations
Special Operators
Aggregate Functions
Limit, Offset & Fetch
Joins
Views
Procedures
Triggers
DCL Commands
TCL Commands
Export/ Import Data
UUID Datatype
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
PHP provides access to a great number of different database systems, many of which are relational in nature and can be interrogated using Structured Query Language (SQL).
Structured Query Language
SQL Commands:
• The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP
Database such as MySQL and SQL server are an integral part of business, hospital, banks and universities. Immensely, Every person who have of access computer or technology eventually work on to store data.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
PostgreSQL Tutorial For Beginners | EdurekaEdureka!
YouTube Link: https://youtu.be/-VO7YjQeG6Y
** MYSQL DBA Certification Training https://www.edureka.co/mysql-dba **
This Edureka PPT on PostgreSQL Tutorial For Beginners (blog: http://bit.ly/33GN7jQ) will help you learn PostgreSQL in depth. You will also learn how to install PostgreSQL on windows. The following topics will be covered in this session:
What is DBMS
What is SQL?
What is PostgreSQL?
Features of PostgreSQL
Install PostgreSQL
SQL Command Categories
DDL Commands
ER Diagram
Entity & Attributes
Keys in Database
Constraints in Database
Normalization
DML Commands
Operators
Nested Queries
Set Operations
Special Operators
Aggregate Functions
Limit, Offset & Fetch
Joins
Views
Procedures
Triggers
DCL Commands
TCL Commands
Export/ Import Data
UUID Datatype
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
PHP provides access to a great number of different database systems, many of which are relational in nature and can be interrogated using Structured Query Language (SQL).
Structured Query Language
SQL Commands:
• The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP
Understanding the SQL aspects of Spark - Spark SQL.pptxKnoldus Inc.
Spark SQL is a module in Apache Spark that provides a programming interface for working with structured and semi-structured data using the power of distributed computing. Not only this it seamlessly integrates relational processing capabilities with Spark's high-performance distributed processing engine.
Access Data from XPages with the Relational ControlsTeamstudio
Did you know that Domino and XPages allows for the easy access of relational data? These exciting capabilities in the Extension Library can greatly enhance the capability of your applications and allow access to information beyond Domino. Howard and Paul will discuss what you need to get started, what controls allow access to relational data, and the new @Functions available to incorporate relational data in your Server Side JavaScript programming.
This chapter covers the following:
- What is SQL
- Categories of SQL statements
- History of SQL
- Relational Database Structure
- MySQL Setup for practice
- SQL Basics (Lexical elements, Data types, Literals)
PL/SQL is a standard and portable language for Oracle Database development. If you develop a program that executes on an Oracle Database, you can quickly move it to another compatible Oracle Database without any changes. PL/SQL is an embedded language. PL/SQL only can execute in an Oracle Database.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Database part2-
1. Course code: ITI131
Course title : Database
PART: 2
Prof. Taymoor Mohamed Nazmy
Dept. of computer science, faculty of computer science, Ain Shams uni.
Ex-vice dean of post graduate studies and research Cairo, Egypt
1
3. Relational algebra, SQL, and the DBMS?
parser
SQL
Relational
algebra
expression
Optimized
Relational
algebra
expression
Query optimizer
Code
generator
Query
execution
plan
Executable
code
DBMS
4. Introduction
• Query language is a language in which user requests information
from the database. it can be categorized as either procedural or
nonprocedural.
• In a procedural language the user instructs the system to do a
sequence of operations on database to compute the desired result.
• In nonprocedural language the user describes the desired
information without giving a specific procedure for obtaining that
information.
• The relational algebra is a procedural query language. It consists of
a set of operations that take one or two relations as input and
produces a new relation as output
5. 5
Relational Query Languages
• Languages for describing queries on a relational
database
• Structured Query Language (SQL)
– Predominant application-level query language
– Declarative
• Relational Algebra
– Intermediate language used within DBMS
– Procedural
• To process a query, a DBMS translates SQL into a
notation similar to relational algebra.
6. Relational Algebra
• Relational Algebra is a procedural
language that can be used to tell
the DBMS ( Data Base Management
System) how to build a new relation from
one or more relations in the database.
6
7. 7
Formal Relational Query Languages
Two mathematical Query Languages form the basis for
formal relational query languages:
• Relational Algebra: More operational, very useful for
representing execution plans.
• Relational Calculus: Lets users describe what they want,
rather than how to compute it. (Non-operational,
declarative.)
Understanding Algebra & Calculus is key to
understanding SQL, query processing!
10. 10
Example Instances
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
S2
• Consider the following
instances R1, S1, S2.
11. Basic Relational Algebra Operations (Unary):
Selection, Projection
Selection: <condition(s)> (<relation>)
• Picks tuples from the relation
Projection: <attribute-list> (<relation>)
• Picks columns from the relation
12. 12
Selection ( )
rating
S
8
2( )
sid sname rating age
28 yuppy 9 35.0
58 rusty 10 35.0
sname rating
yuppy 9
rusty 10
))2(
8
(
,
S
ratingratingsname
• Selects rows that satisfy selection
condition.
• No duplicates in result! (Why?)
• Schema of result identical to
schema of (only) input relation.
• Result relation can be the input for
another relational algebra
operation! (Operator
composition.)
S2
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
13. 13
Projection ( )
sname rating
yuppy 9
lubber 8
guppy 5
rusty 10
sname rating
S
,
( )2
age
35.0
55.5
age S( )2
• Deletes attributes that are not in projection list.
• Schema of result contains exactly the fields in the
projection list, with the same names that they had
in the (only) input relation.
• Projection operator has to eliminate duplicates!
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
S2
14. Relational Algebra Operations (Set):
Union, Set Difference, and intersection
Union: (<relation>) U (<relation>)
• New relation contains all tuples from both relations,
duplicate tuples eliminated.
Set Difference: R – S
• Produces a relation with tuples that are in R but NOT in S.
Intersection:
R S
• All tuples that are in both R and S
16. Relational Algebra Operations (Set):
Cartesian Product, Intersect
Cartesian Product: R x S
• Produces a relation that is concatenation of
every tuple of R with every tuple of S
• The Above operations are the 5 fundamental
operations of relational algebra.
17. 17
Cross-Product ()
• S1 R1 : Each row of S1 is paired with each row of R1.
• Result schema has one field per field of S1 and R1, with field
names `inherited’ if possible.
– Conflict: Both S1 and R1 have a field called sid.
(sid) sname rating age (sid) bid day
22 dustin 7 45.0 22 101 10/10/96
22 dustin 7 45.0 58 103 11/12/96
31 lubber 8 55.5 22 101 10/10/96
31 lubber 8 55.5 58 103 11/12/96
58 rusty 10 35.0 22 101 10/10/96
58 rusty 10 35.0 58 103 11/12/96
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
19. Introduction
• SQl designed for managing data held in a relational
database management system (RDBMS),
• Originally based upon relational algebra and tuple
relational calculus, SQL consists of a data definition
language, data manipulation language, and data control
language.
• The scope of SQL includes data insert, query, update
and delete, schema creation and modification, and data
access control.
20. History of SQL
• SQL: Structured Query Language, used to be called SEQEL
• SQL is based on the relational tuple calculus
• SEQUEL: It was designed by IBM Research as the interface for
an experimental relational database system called SYSTEM R.
1974.
• SQL/86: ANSI & ISO standard
• SQL/89: ANSI & ISO standard
• SQL/92 or SQL2: ANSI & ISO standard
• SQL3: in the works...
• SQL2 supported by RDMS such as:
• ORACLE, SYBASE, INFORMIX, IBM DB2, SQL SERVER,
and Open Source’s MySQL,
21. Extended Versions of SQL
• However most Database Management Systems (DBMS) provide non-standard
extensions to SQL that include procedural elements, the following table show some
of those extensions:
Source Common name Full name
ANSI/ISO Standard SQL/PSM SQL/Persistent Stored Modules
Interbase / Firebird PSQL Procedural SQL
IBM DB2 SQL PL
SQL Procedural Language (implements
SQL/PSM)
IBM Informix SPL Stored Procedural Language
IBM Netezza NZPLSQL[18] (based on Postgres PL/pgSQL)
Microsoft / Sybase T-SQL
Transact-SQL
Mimer SQL SQL/PSM
SQL/Persistent Stored Module (implements
SQL/PSM)
MySQL SQL/PSM
SQL/Persistent Stored Module (implements
SQL/PSM)
MonetDB SQL/PSM
SQL/Persistent Stored Module (implements
SQL/PSM)
NuoDB SSP
Starkey Stored Procedures
Oracle PL/SQL Procedural Language/SQL (based on Ada)
PostgreSQL PL/pgSQL
Procedural Language/PostgreSQL Structured
Query Language (implements SQL/PSM)
Sybase Watcom-SQL SQLAnywhere Watcom-SQL Dialect
Teradata SPL Stored Procedural Language
SAP SAP HANA SQL Script
22. MySQL
2/7/2020
MySQL is the world's most popular open source database
software, with over 100 million copies of its software
downloaded or distributed throughout it's history.
MySQL is a relational database management system (
RDBMS ) and which runs a server, providing multi-user
access to a number of databases.
With its superior speed, reliability, and ease of use, MySQL
has become the preferred choice for IT in all sectors or
domains.
23. What is SQL?
• When a user wants to get some information
• from a database file, he can issue a query.
• – A query is a user–request to retrieve data or
• information with a certain condition.
• – SQL is a query language that allows user to
• specify the conditions. (instead of algorithms)
23
25. DML (Data Manipulation Language)
• DML statements affect records in a table. These
are basic operations we perform on data such as
selecting a few records from a table, inserting new
records, deleting unnecessary records, and
updating/modifying existing records.
• DML statements include the following:
• SELECT – select records from a table
INSERT – insert new records
UPDATE – update/Modify existing records
DELETE – delete existing records
26. DDL (Data Definition Language)
• DDL statements are used to alter/modify a
database or table structure and schema. These
statements handle the design and storage of
database objects.
• CREATE – create a new Table, database, schema
ALTER – alter existing table, column description
DROP – delete existing objects from database
27. DCL (Data Control Language)
• DCL statements control the level of access that
users have on database objects.
• GRANT – allows users to read/write on
certain database objects
•
REVOKE – keeps users from read/write
permission on database objects
28. TCL (Transaction Control Language)
• TCL statements allow you to control and manage
transactions to maintain the integrity of data
within SQL statements.
• BEGIN Transaction – opens a transaction
COMMIT Transaction – commits a transaction
•
ROLLBACK Transaction – ROLLBACK a
transaction in case of any error
29. Using SQL in Your Web Site
• To build a web site that shows data from a database,
you will need:
• An RDBMS database program (i.e. MS Access, SQL
Server, MySQL)
• To use a server-side scripting language, like PHP or
ASP
• To use SQL to get the data you want to use HTML /
CSS to style the page
30. 30
Using SQL
SQL statements can be embedded into a program (cgi or
perl script, Visual Basic, MS Access)
OR
SQL statements can be entered directly at the
command prompt of the SQL software being used
(such as mySQL)
31. Keep in Mind that
• SQL keywords are NOT case sensitive: select is
the same as SELECT.
• 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.
32. SQL Statements, Operations, Clauses
SQL Statements such as :
Select
SQL Operations such as:
Join
Left Join
Right Join
Like
SQL Clauses such as:
Order By
Group By
Having
33. Some of The Most Important SQL Statements
• 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
36. CHARACTER [(length)] or CHAR [(length)]
• The CHARACTER data type accepts character strings,
including Unicode, of a fixed length. The length of the
character string should be specified in the data type
declaration; for example, CHARACTER(n) where n represents
the desired length of the character string.
• If no length is specified during the declaration, the default
length is 1. Used to store character string value of fixed
length.
• The maximum no. of characters the data type can hold is 255
characters. It's 50% faster than VARCHAR. Any remaining
space in the field is padded with blanks.
37. CHARACTER [(length)] or CHAR [(length)]
• CHAR(10) or CHARACTER(10)
• Valid
• 'Race car'
• 'RACECAR'
• '24865'
• '1998-10-25'
• '1998-10-25 ' (Blank characters are truncated)
•
Invalid
24865
1998-10-25
'Date: 1998-10-25'
38. VARCHAR (length)
• The VARCHAR data type accepts character strings, including Unicode, of
a variable length is up to the maximum length specified in the data type
declaration.
• Examples
• VARCHAR(10)
• Valid
• 'Race car'
• 'RACECAR'
• '24865'
• '1998-10-25'
• '1998-10-25 '
Invalid
24865
1998-10-25
'Date: 1998-10-25'
39. BOOLEAN
• The BOOLEAN data type supports the storage of two values: TRUE or
FALSE. No parameters are required when declaring a BOOLEAN data type.
• Examples
• BOOLEAN
• Valid
• TRUE
• true
• True
• False
Invalid
1
0
Yes
No
40. SMALLINT
• The SMALLINT data type accepts numeric values with an implied scale of
zero. It stores any integer value between the range 2^ -15 and 2^15-1.
• SMALLINT
• Valid
• -32768
• 0
• -30.3 (digits to the right of the
• decimal point are truncated)
• 32767
Invalid
-33,000,567
1,897,536,000
41. INTEGER or INT
• The INTEGER data type accepts numeric values with an implied
scale of zero. It stores any integer value between the range 2^ -31
and 2^31 -1
• Examples INTEGER or INT
• Valid
• -2147483648
• -1025
• 0
• 1025.98 (digits to the right of the
• decimal point are truncated)
• 2147483647
Invalid
-1,025,234,000,367
1,025,234,000,367
42. DECIMAL [(p[,s])] or DEC [(p[,s])]
• The DECIMAL data type accepts numeric values, for which you may
define a precision and a scale in the data type declaration.
• The precision is an integer that indicates the number of digits that the
number will contain. The scale is an integer that indicates the number of
these digits that will represent decimal places to the right of the decimal
point.
• Examples DECIMAL(10,3)
•
• Valid
• 1234567
• 1234567.123
• -1234567
Invalid
12345678
12345678.12
12345678.123
-12345678
-12345678.12
-12345678.123
43. REAL
• The REAL data type accepts approximate numeric values, up to a precision of 64.
No parameters are required when declaring a REAL data type. If you attempt to
assign a value with a precision greater than 64 an error is raised.
• Examples
• REAL
• Valid
• -2345
• 0
• 1E-3
• 1.245
• 123456789012345678901234567890
Invalid
123,456,789,012,345,678,901,234,567,890,123
44. DATE
• The DATE data type accepts date values. No parameters are
required when declaring a DATE data type. Date values
should be specified in the form: YYYY-MM-DD. However,
PointBase will also accept single digits entries for month
and day values.
• Examples
• DATE
• Valid
• DATE '1999-01-01'
• DATE '2000-2-2'
Invalid
DATE '1999-13-1'
date '2000-2-30'
'2000-2-27'
date 2000-2-27
45. TIME
• The TIME data type accepts time values. No parameters are required
when declaring a TIME data type. time values should be specified in
the form: HH:MM:SS
• Examples
• TIME
• Valid
• TIME '00:00:00'
• TIME '1:00:00'
• TIME '23:59:59'
• time '23:59:59.99'
Invalid
TIME '00:62:00'
TIME '00:3:00'
TIME '23:01'
'24:01:00'
46. TIMESTAMP
• The TIMESTAMP data type accepts timestamp values, which are a
combination of a DATE value and a TIME value.
• Examples TIMESTAMP
• Valid
• TIMESTAMP `1999-12-31 23:59:59.99'
• TIMESTAMP `2000-01-01 00:00:00'
• Invalid
• 1999-00-00 00:00:00
• TIMESTAMP `1999-01-01 00:64:00'
50. DDL statements
The SQL CREATE DATABASE Statement
• The CREATE DATABASE statement is used
to create a new SQL database.
• CREATE DATABASE databasename;
• Exp:
• CREATE DATABASE testDB;
51. • Table and Column names should be meaningful
and reflect the nature of the data that is to be
stored.
• If the data stored is about the products that a
firm sells , then the table should probably be
named product!
• If products are identified by a string of eight
characters, then the column that stores the
product information data should be named
product_number, or product_code.
Naming Tables and Columns
52. • One of the first steps in creating a
database is to create the tables that will
store organization’s data.
• In order to create a table , four pieces of
information must be determined:
1. The table name
2. The column (field) names
3. Column data types and
4. Column sizes
Table Creation
53. SQL CREATE TABLE Statement
• The CREATE TABLE statement is used to create a new
table in a database.
• CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
• The column parameters specify the names of the columns of
the table. The datatype parameter specifies the type of data
the column can hold (e.g. varchar, integer, date, etc.).
55. The SQL DROP TABLE Statement
• The DROP TABLE statement is used to drop
an existing table in a database.
• DROP TABLE table_name;
• Exp:
• DROP TABLE Shippers;
56. SQLALTER TABLE Statement
• The ALTER TABLE statement is used to add,
delete, or modify columns in an existing table.
• The ALTER TABLE statement is also used to
add and drop various constraints on an existing
table.
• ALTER TABLE table_name(
ADD column_name datatype);
57. ALTER TABLE - DROP COLUMN
• To delete a column in a table, use the
following syntax (notice that some database
systems don't allow deleting a column):
• ALTER TABLE table_name (
DROP COLUMN column_name);
58. Example:
CREATE TABLE FoodCart (
date varchar(10),
food varchar(20),
profit float
);
ALTER TABLE FoodCart (
ADD sold int
);
ALTER TABLE FoodCart(
DROP COLUMN profit
);
DROP TABLE FoodCart;
profitfooddate
soldprofitfooddate
soldfooddate
FoodCart
FoodCart
FoodCart
59. SQL: UPDATE Statement
To update the content of the table:
UPDATE statement syntax:
UPDATE table name SET <attr> = <value>
WHERE <selection condition>;
Example: UPDATE FoodCart SET sold = 349
WHERE date = ’02/25/08’AND food = ‘pizza’;
FoodCart FoodCart (updated)
70pizza02/26/08
500hotdog02/26/08
350pizza02/25/08
soldfooddate
70pizza02/26/08
500hotdog02/26/08
349pizza02/25/08
soldfooddate
• Example conditions:
– sold < 40
– food = ‘pizza’
60. SQL: DELETE Statement
To delete rows from the table:
DELETE statement syntax:
DELETE FROM <table name>
WHERE <condition>;
Example: DELETE FROM FoodCart
WHERE food = ‘hotdog’;
FoodCart
FoodCart
Note: If the WHERE clause is omitted all rows of data are deleted from the table.
70pizza02/26/08
500hotdog02/26/08
349pizza02/25/08
soldfooddate
70pizza02/26/08
349pizza02/25/08
soldfooddate
61. DML statements
The SELECT statement
• The SELECT statement is the core of SQL,
and it is likely that the vast majority of your
SQL commands will be SELECT statements.
• The SELECT statement is used to query the
database and retrieve selected data that match
the criteria that you specify.
62. SQL: SELECT Statement
A basic SELECT statement includes 3 clauses
SELECT <attribute name> FROM <tables> WHERE <condition>
SELECT
Specifies the attributes
that are part of the
resulting relation
FROM
Specifies the tables
that serve as the input
to the statement
WHERE
Specifies the selection
condition, including
the join condition.
Note: that you don't need to use WHERE
63. • SELECT column1, column2, ...
FROM table_name
WHERE condition;
• AND Syntax
• SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND
condition3 ...;
64. • OR Syntax
• SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR
condition3 ...;
• NOT Syntax
• SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
65. Examples
• SELECT * FROM Customers
WHERE Country='Germany' AND
City='Berlin';
• SELECT * FROM Customers
WHERE City='Berlin' OR City='München';
• SELECT * FROM Customers
WHERE NOT Country='Germany';
66. • SELECT * FROM Customers
WHERE Country='Germany' AND
(City='Berlin' OR City='München');
• SELECT * FROM Customers
WHERE NOT Country='Germany' AND NOT
Country='USA';
67. Using a “*” in a select statement indicates that
every attribute of the input table is to be selected.
Example: SELECT * FROM … WHERE …;
To get unique rows, type the keyword
DISTINCT after SELECT.
Example: SELECT DISTINCT * FROM …
WHERE …;
SQL: SELECT Statement (cont.)
68. Example Tables
Student
ID First Last
S103 John Smith
S104 Mary Jones
S105 Jane Brown
S106 Mark Jones
S107 John Brown
Course
Code Title
DBS Database Systems
PR1 Programming 1
PR2 Programming 2
IAI Intro to AI
Grade
ID Code Mark
S103 DBS 72
S103 IAI 58
S104 PR1 68
S104 IAI 65
S106 PR2 43
S107 PR1 76
S107 PR2 60
S107 IAI 35
69. DISTINCT and ALL
• Sometimes you end up with
duplicate entries
• Using DISTINCT removes
duplicates
• Using ALL retains them -
this is the default
SELECT ALL Last
FROM Student
SELECT DISTINCT Last
FROM Student
Last
Smith
Jones
Brown
Jones
Brown
Last
Smith
Jones
Brown
70. WHERE Clauses
• Usually you don’t want all
the rows
– A WHERE clause restricts
the rows that are returned
– It takes the form of a
condition - only those rows
that satisfy the condition are
returned
• Example conditions:
– Mark < 40
– First = ‘John’
– First <> ‘John’
– First = Last
– (First = ‘John’) AND
(Last = ‘Smith’)
– (Mark < 40) OR (Mark >
70)
71. WHERE Examples
SELECT * FROM Grade
WHERE Mark >= 60;
SELECT DISTINCT ID
FROM Grade
WHERE Mark >= 60;
ID Code Mark
S103 DBS 72
S104 PR1 68
S104 IAI 65
S107 PR1 76
S107 PR2 60
ID
S103
S104
S107
73. SQL: The ORDER BY Clause
Ordered result selection
desc (descending order)
SELECT *
FROM emp
order by state desc;
puts state in descending order, e.g. TN, MA, CA
asc (ascending order)
SELECT *
FROM emp
order by id asc;
puts ID in ascending order, e.g. 1001, 1002, 1003
74. The SQL COUNT(), AVG() and SUM() Functions
• The COUNT() function returns the number of rows that matches a
specified criteria.
• SELECT COUNT(column_name)
FROM table_name
WHERE condition;
• The AVG() function returns the average value of a numeric column.
• SELECT AVG(column_name)
FROM table_name
WHERE condition;
• The SUM() function returns the total sum of a numeric column.
• SELECT SUM(column_name)
FROM table_name
WHERE condition;
75. As
• Use as to put the output of any operation in new
column and specify this name
• Example:
• SELECT AVG(price) as average;
• The average will calculated for the column of
name price and put the result in a new coulmn of
name average.
76. SQL: The GROUP BY Clause
The function to divide the tuples into groups and returns an aggregate for each
group.
Usually, it is an aggregate function’s companion
SELECT food, sum(sold) as totalSold
FROM FoodCart
group by food;
FoodCart
419pizza
500hotdog
totalSoldfood
70pizza02/26/08
500hotdog02/26/08
349pizza02/25/08
soldfooddate
77. The SQL MIN() and MAX() Functions
• The MIN() function returns the smallest value of the
selected column.
• SELECT MIN(column_name)
FROM table_name
WHERE condition;
• The MAX() function returns the largest value of the
selected column.
• SELECT MAX(column_name)
FROM table_name
WHERE condition;
78. Example
• SELECT MAX(Price) AS LargestPrice
FROM Products;
• SELECT MIN(Price) AS SmallestPrice
FROM Products;
79. SELECT from Multiple Tables
• Often you need to combine
information from two or
more tables
• You can get the effect of a
product by using
SELECT * FROM Table1, Table2...
• If the tables have columns
with the same name
ambiguity results
• You resolve this by
referencing columns with
the table name
TableName.Column
80. SELECT from Multiple Tables
ID First Last ID Code Mark
S103 John Smith S103 DBS 72
S103 John Smith S103 IAI 58
S104 Mary Jones S104 PR1 68
S104 Mary Jones S104 IAI 65
S106 Mark Jones S106 PR2 43
S107 John Brown S107 PR1 76
S107 John Brown S107 PR2 60
SELECT ... FROM Student, Grade
WHERE (Student.ID = Grade.ID) AND (Mark >= 40);
Student
ID First Last
S103 John Smith
S104 Mary Jones
S105 Jane Brown
S106 Mark Jones
S107 John Brown
Grade
ID Code Mark
S103 DBS 72
S103 IAI 58
S104 PR1 68
S104 IAI 65
S106 PR2 43
S107 PR1 76
S107 PR2 60
S107 IAI 35
81. SELECT from Multiple Tables
• Suppose you have
another table, with
name course
Find the output of the
following statements:
SELECT * FROM
Student, Grade, Course
WHERE
Student.ID = Grade.ID
AND
Course.Code = Grade.Code
82. SELECT from Multiple Tables
ID First Last ID Code Mark Code Title
S103 John Smith S103 DBS 72 DBS Database Systems
S103 John Smith S103 IAI 58 IAI Intro to AI
S104 Mary Jones S104 PR1 68 PR1 Programming 1
S104 Mary Jones S104 IAI 65 IAI Intro to AI
S106 Mark Jones S106 PR2 43 PR2 Programming 2
S107 John Brown S107 PR1 76 PR1 Programming 1
S107 John Brown S107 PR2 60 PR2 Programming 2
S107 John Brown S107 IAI 35 IAI Intro to AI
Student Grade Course
Student.ID = Grade.ID Course.Code = Grade.Code
SELECT * FROM Student, Grade, Course
WHERE
Student.ID = Grade.ID AND Course.Code = Grade.Code
83. SQL: Join operation
A join (inner join) can be specified in the FROM
clause which list the two input relations.
Example:
Biotech1003
Sales1002
IT1001
DivisionID
TN1002
MA1001
CA1000
StateID
Emp Dept
86. INSERT INTO Syntax
• The INSERT INTO statement is used to insert
new records in a table.
• INSERT INTO table_name (column1,
column2, column3, ...)
•
VALUES (value1, value2, value3, ...);
88. Comments
• comments start with /* and end with */.
• Any text between /* and */ will be ignored.
• /*Select all the columns
of all the records
in the Customers table:*/
SELECT * FROM Customers;
89. SQL Constraints
• SQL constraints are used to specify rules for the data in a table.
• If there is any violation between the constraint and the data action,
the action is aborted.
• Constraints can be column level or table level. Column level
constraints apply to a column, and table level constraints apply to
the whole table.
• Examples of constraints:
• keys, domain constraints, tuple constraints.
90. SQL contrains
• The following constraints are commonly used in SQL:
• NOT NULL - Ensures that a column cannot have a NULL value
• UNIQUE - Ensures that all values in a column are different
• CHECK - Ensures that all values in a column satisfies a specific condition
• PRIMARY KEY - A combination of a NOT NULL and UNIQUE.
Uniquely identifies each row in a table
• FOREIGN KEY - Uniquely identifies a row/record in another table
• DEFAULT - Sets a default value for a column when no value is specified
91. SQL NOT NULL Constraint
• By default, a column can hold NULL values.
• The NOT NULL constraint enforces a column
to NOT accept NULL values.
• This enforces a field to always contain a value,
which means that you cannot insert a new
record, or update a record without adding a
value to this field.
92. • Exp:
• CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255) NOT NULL,
Age int
);
93. SQL UNIQUE Constraint
• The UNIQUE constraint ensures that all values in a column
are different.
• Both the UNIQUE and PRIMARY KEY constraints provide
a guarantee for uniqueness for a column or set of columns.
• A PRIMARY KEY constraint automatically has a UNIQUE
constraint.
• However, you can have many UNIQUE constraints per
table, but only one PRIMARY KEY constraint per table.
94. • CREATE TABLE Persons (
ID int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
);
95. Check or Table Constraints
CREATE TABLE Sailors
( sid INTEGER,
sname CHAR(10),
rating INTEGER,
age REAL,
CHECK ( rating >= 1 AND rating <= 10 ));
Check constrain keep the values in the attribute
rating between 1 and 10
96. SQL PRIMARY KEY Constraint
• The PRIMARY KEY constraint uniquely
identifies each record in a database table.
• Primary keys must contain UNIQUE values,
and cannot contain NULL values.
• A table can have only one primary key, which
may consist of single or multiple fields.
97. • CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);
98. SQL PRIMARY KEY on ALTER TABLE
• To create a PRIMARY KEY constraint on the
"ID" column when the table is already created,
use the following SQL:
• ALTER TABLE Persons
ADD PRIMARY KEY (ID);
• ALTER TABLE Persons
DROP PRIMARY KEY;
99. SQL FOREIGN KEY CONSTRAINT
• The SQL FOREIGN KEY CONSTRAINT is used
to ensure the referential integrity of the data in
one table to match values in another table.
The FOREIGN KEY CONSTRAINT is a column
or list of columns which points to the PRIMARY
KEY of another table.
The main purpose of FOREIGN KEY is, only
those values will appear which are present in the
primary key table.
100. Field Name Data Type Size
Decimal
Places
NULL Constraint
agent_code char 6 No
PRIMARY
KEY
agent_name char 40 No
working_area char 35 Yes
commission decimal 10 2 Yes
phone_no char 17 Yes
agents
Field Name Data Type Size
Decimal
Places
NULL Constraint
cust_code char 6 No
PRIMARY
KEY
cust_name char 25 Yes
cust_city char 25 Yes
agent_code char 6 Yes
FOREIGN
KEY
customer1
102. SQL DEFAULT Constraint
• The DEFAULT constraint is used to provide a
default value for a column.
• The default value will be added to all new
records IF no other value is specified.
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
City varchar(255) DEFAULT 'Sandnes'
);
106. 106
Rows describe
the Occurrence
of an Entity
Table Design
Name Address
Jane Doe 123 Main Street
John Smith 456 Second Street
Mary Poe 789 Third Ave
Columns describe one
characteristic of the entity
107. 107
Using SQL
To begin, you must first CREATE a database using the
following SQL statement:
CREATE DATABASE database_name
108. 108
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_id auth_name
(9 digit int) (40 char string)
109. 109
Data Retrieval (Queries)
• Queries search the database, fetch info,
and display it. This is done using the
keyword SELECT
SELECT * FROM publishers
pub_id pub_name address state
0736 New Age Books 1 1st Street MA
0987 Binnet & Hardley 2 2nd Street DC
1120 Algodata Infosys 3 3rd Street CA
The
*Operator asks for every column in the table.
110. 110
Data Retrieval (Queries)
• Queries can be more specific with a few
more lines
pub_id pub_name address state
0736 New Age Books 1 1st Street MA
0987 Binnet & Hardley 2 2nd Street DC
1120 Algodata Infosys 3 3rd Street CA
Only publishers in CA are displayed
SELECT *
from publishers
where state = ‘CA’
111. 111
Data Input
• Putting data into a table is accomplished
using the keyword INSERT
pub_id pub_name address state
0736 New Age Books 1 1st Street MA
0987 Binnet & Hardley 2 2nd Street DC
1120 Algodata Infosys 3 3rd Street CA
Table is updated with new information
INSERT INTO publishers
VALUES (‘0010’, ‘pragmatics’, ‘4 4th Ln’, ‘il’)
pub_id pub_name address state
0010 Pragmatics 4 4th Ln IL
0736 New Age Books 1 1st Street MA
0987 Binnet & Hardley 2 2nd Street DC
1120 Algodata Infosys 3 3rd Street CA
Keyword
Variable
112. 112
Using SQL
• To insert data in the current table, use the
keyword INSERT INTO
auth_id auth_name
Then issue the statement
SELECT * FROM authors
INSERT INTO authors
values(‘000000001’, ‘John Smith’)
000000001 John Smith
113. 113
Using SQL
SELECT auth_name, auth_city
FROM publishers
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
auth_name auth_city
Jane Doe Dearborn
John Smith Taylor
If you only want to display the author’s name and city from the following
table:
114. 114
Using SQL
DELETE from authors
WHERE auth_name=‘John Smith’
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
To delete data from a table, use the DELETE statement:
115. 115
Using SQL
UPDATE authors
SET auth_name=‘hello’
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
To Update information in a database use the UPDATE keyword
Hello
Hello
Sets all auth_name fields to hello
116. 116
Using SQL
ALTER TABLE authors
ADD birth_date datetime null
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
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
.
.
117. 117
Using SQL
ALTER TABLE authors
DROP birth_date
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
To delete a column or row, use the keyword DROP
DROP removed the birth_date characteristic from the table
auth_state
.
.
118. 118
Using SQL
DROP DATABASE authors
auth_id auth_name auth_city auth_state
123456789 Jane Doe Dearborn MI
000000001 John Smith Taylor MI
The DROP statement is also used to delete an entire database.
DROP removed the database and returned the memory to system
119. SQL examples
• CREATE TABLE STATION
(ID INTEGER PRIMARY KEY,
CITY CHAR(20),
STATE CHAR(2),
LAT_N REAL,
LONG_W REAL);
• INSERT INTO STATION VALUES (13, 'Phoenix', 'AZ', 33, 112);
INSERT INTO STATION VALUES (44, 'Denver', 'CO', 40, 105);
INSERT INTO STATION VALUES (66, 'Caribou', 'ME', 47, 68);
• SELECT LAT_N, CITY, TEMP_F
FROM STATS, STATION
WHERE MONTH = 7
AND STATS.ID = STATION.ID
ORDER BY TEMP_F;
123. SQL Statement Syntax
AND / OR
SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
ALTER TABLE
ALTER TABLE table_name
ADD column_name datatypeor
ALTER TABLE table_name
DROP COLUMN column_name
AS (alias)
SELECT column_name AS column_alias
FROM table_nameor
SELECT column_name
FROM table_name AS table_alias
CREATE VIEW
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
124. BETWEEN
SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
CREATE DATABASE CREATE DATABASE database_name
CREATE TABLE
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
...
)
CREATE INDEX
CREATE INDEX index_name
ON table_name (column_name)or
CREATE UNIQUE INDEX index_name
ON table_name (column_name)
125. DELETE
DELETE FROM table_name
WHERE some_column=some_valueor
DELETE FROM table_name
(Note: Deletes the entire table!!)
DELETE * FROM table_name
(Note: Deletes the entire table!!)
DROP DATABASE DROP DATABASE database_name
DROP INDEX
DROP INDEX table_name.index_name
(SQL Server)
DROP INDEX index_name ON
table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
126. DROP TABLE DROP TABLE table_name
EXISTS
IF EXISTS (SELECT * FROM table_name WHERE id =
?)
BEGIN
--do what needs to be done if exists
END
ELSE
BEGIN
--do what needs to be done if not
END
GROUP BY
SELECT column_name,
aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING
SELECT column_name,
aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator
value
127. IN
SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
INSERT INTO
INSERT INTO table_name
VALUES (value1, value2, value3,....)or
INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)
INNER JOIN
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LEFT JOIN
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
128. RIGHT JOIN
SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON
table_name1.column_name=table_name2.colum
n_name
FULL JOIN
SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON
table_name1.column_name=table_name2.colum
n_name
LIKE
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
ORDER BY
SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
SELECT
SELECT column_name(s)
FROM table_name
129. SELECT *
SELECT *
FROM table_name
SELECT DISTINCT
SELECT DISTINCT column_name(s)
FROM table_name
SELECT INTO
SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_nameor
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name
SELECT TOP
SELECT TOP number|percent
column_name(s)
FROM table_name
TRUNCATE TABLE TRUNCATE TABLE table_name
130. UNION
SELECT column_name(s) FROM
table_name1
UNION
SELECT column_name(s) FROM
table_name2
UNION ALL
SELECT column_name(s) FROM
table_name1
UNION ALL
SELECT column_name(s) FROM
table_name2
UPDATE
UPDATE table_name
SET column1=value, column2=value,...
WHERE some_column=some_value
WHERE
SELECT column_name(s)
FROM table_name
WHERE column_name operator value