Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
SQL Basics

SQL Basics

Ratings:

5.0

(1)
|Views: 340|Likes:
Published by Kapil Samadhiya
This document is very useful for Software Testing / Quality Assurance concepts.


GOOD LUCK !

Kapil Samadhiya
This document is very useful for Software Testing / Quality Assurance concepts.


GOOD LUCK !

Kapil Samadhiya

More info:

Published by: Kapil Samadhiya on Aug 06, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/21/2010

pdf

text

original

 
SQL Basic
SQL IntroductionDescribes what SQL is, and how it can be used.SQL SELECTHow to use the SELECT statement to select data from a table in SQL.SQL WHEREHow to use the WHERE clause to specify a criterion for the selection.SQL INSERT INTOHow to use the INSERT INTO statement to insert new rows into a table.SQL UPDATEHow to use the UPDATE statement to update or change rows in a table.SQL DELETEHow to use the DELETE statement to delete rows in a table.
SQL Demo
SQL Try ItTest your SQL skills!
SQL Advanced
SQL ORDER BYHow to use the ORDER BY keywords to return rows in a defined order.SQL AND & OR How to use AND and OR to join two or more conditions in a WHERE clause.SQL INHow to use the IN operator.SQL BETWEEN...ANDHow to use BETWEEN....AND to find data in a range.SQL AliasesHow to use aliases for column names and table names.SQL JOINHow to select information from multiple tables.SQL UNIONHow to select information from two tables with the UNION and UNION ALL commands.SQL CREATEHow to create databases, tables, and indices.SQL DROPHow to delete databases, tables, and indices.SQL ALTER TABLEHow to use the ALTER TABLE statement to add or drop columns in an existing table.SQL FunctionsHow to use the built-in functions in SQL.SQL GROUP BYHow to use the built-in GROUP BY function in SQL.SQL SELECT INTOHow to use the SELECT INTO statement to create backup copies of tables.
 
SQL is a standard computer language for accessing and manipulating databases.
What is SQL?
 
SQL stands for 
S
tructured
Q
uery
L
anguage
 
SQL allows you to access a database
 
SQL is an ANSI standard computer language
 
SQL can execute queries against a database
 
SQL can retrieve data from a database
 
SQL can insert new records in a database
 
SQL can delete records from a database
 
SQL can update records in a database
 
SQL is easy to learn
SQL is a Standard - BUT....
SQL is an ANSI (American National Standards Institute) standard computer language for accessing andmanipulating database systems. SQL statements are used to retrieve and update data in a database. SQL works withdatabase programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, etc.Unfortunately, there are many different versions of the SQL language, but to be in compliance with the ANSIstandard, they must support the same major keywords in a similar manner (such as SELECT, UPDATE, DELETE,INSERT, WHERE, and others).
Note:
Most of the SQL database programs also have their own proprietary extensions in addition to the SQLstandard!
SQL Database Tables
A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.Below is an example of a table called "Persons":
LastNameFirstNameAddressCity
HansenOlaTimoteivn 10SandnesSvendsonToveBorgvn 23SandnesPettersenKariStorgt 20StavangeThe table above contains three records (one for each person) and four columns (LastName, FirstName, Address, andCity).
SQL Queries
With SQL, we can query a database and have a result set returned.A query like this:
SELECT LastName FROM Persons
Gives a result set like this:
LastName
HansenSvendsonPettersen
Note
: Some database systems require a semicolon at the end of the SQL statement. We don't use the semicolon inour tutorials.
 
SQL Data Manipulation Language (DML)
SQL (Structured Query Language) is a syntax for executing queries. But the SQL language also includes a syntax toupdate, insert, and delete records.These query and update commands together form the Data Manipulation Language (DML) part of SQL:
 
SELECT
- extracts data from a database table
 
UPDATE
- updates data in a database table
 
DELETE
- deletes data from a database table
 
INSERT INTO
- inserts new data into a database table
SQL Data Definition Language (DDL)
The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can alsodefine indexes (keys), specify links between tables, and impose constraints between database tables.The most important DDL statements in SQL are:
 
CREATE TABLE
- creates a new database table
 
ALTER TABLE
- alters (changes) a database table
 
DROP TABLE
- deletes a database table
 
CREATE INDEX
- creates an index (search key)
 
DROP INDEX
- deletes an index
The SELECT Statement
The SELECT statement is used to select data from a table. The tabular result is stored in a result table (called theresult-set).
Syntax
SELECT column_name(s)FROM table_name
Select Some Columns
To select the columns named "LastName" and "FirstName", use a SELECT statement like this:
SELECT LastName,FirstName FROM Persons
"Persons" tableLastNameFirstNameAddressCity
HansenOlaTimoteivn 10SandnesSvendsonToveBorgvn 23SandnesPettersenKariStorgt 20Stavange
ResultLastNameFirstName
HansenOlaSvendsonTovePettersenKari
Select All Columns
To select all columns from the "Persons" table, use a * symbol instead of column names, like this:
SELECT * FROM Persons
ResultLastNameFirstNameAddressCity

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->