0% found this document useful (0 votes)
5 views3 pages

SQLnotes

SQL, or Structured Query Language, is a standard language for accessing and manipulating relational databases, allowing users to execute queries, retrieve, insert, update, and delete data. It became an ANSI and ISO standard in the mid-1980s, and while SQL is standardized, various versions exist. Key SQL commands include SELECT, UPDATE, DELETE, and INSERT, with specific syntax for operations like retrieving distinct values from tables.

Uploaded by

Vaishnavi Argade
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
5 views3 pages

SQLnotes

SQL, or Structured Query Language, is a standard language for accessing and manipulating relational databases, allowing users to execute queries, retrieve, insert, update, and delete data. It became an ANSI and ISO standard in the mid-1980s, and while SQL is standardized, various versions exist. Key SQL commands include SELECT, UPDATE, DELETE, and INSERT, with specific syntax for operations like retrieving distinct values from tables.

Uploaded by

Vaishnavi Argade
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

SQL:

 SQL is a standard language for storing, manipulating and retrieving data


in databases.
 SELECT * FROM Customers;
 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 American National Standards
Institute (ANSI) in 1986, and of the International Organization for
Standardization (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 ,delete records in a database
- SQL can create new databases.

 SQL is a Standard - BUT....


 Although SQL is an ANSI/ISO standard, there are different versions of the
SQL language.

 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

RDBMS:
 RDBMS stands for Relational Database Management System.
 RDBMS is the basis for SQL, and for all modern database systems such as
MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.
 The data in RDBMS is stored in database objects called tables. A table is
a collection of related data entries and it consists of columns and rows.

Database Tables:
-A database most often contains one or more tables. Each table is identified by
a name (e.g. "Customers" or "Orders"), and contain records (rows) with data.

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 .

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

1. SQL SELECT Statement:

- The SELECT statement is used to select data from a database.


Example:
Return data from the Customers table:

SELECT CustomerName, City FROM Customers;

Syntax
SELECT column1, column2, ...
FROM table_name;

2.SELECT DISTINCT Statement:


-The SELECT DISTINCT statement is used to return only distinct (different)
values.
-Example
Select all the different countries from the "Customers" table:
SELECT DISTINCT Country FROM Customers;
-Inside a table, a column often contains many duplicate values; and sometimes
you only want to list the different (distinct) values.

Syntax
SELECT DISTINCT column1, column2, ...
FROM table_name;

SELECT Example Without DISTINCT


If you omit the DISTINCT keyword, the SQL statement returns the "Country"
value from all the records of the "Customers" table:
Example
SELECT Country FROM Customers;

Count Distinct
By using the DISTINCT keyword in a function called COUNT, we can return the
number of different countries.
Example
SELECT COUNT(DISTINCT Country) FROM Customers;
Note: The COUNT(DISTINCT column_name) is not supported in Microsoft
Access databases.
Here is a workaround for MS Access:
Example
SELECT Count(*) AS DistinctCountries
FROM (SELECT DISTINCT Country FROM Customers);

You might also like