0% found this document useful (0 votes)
40 views

Structured Query Language

Structured Query Language (SQL) is used to access and modify relational databases. A relational database contains a collection of tables without physical pointers. SQL statements like CREATE, INSERT, UPDATE, DELETE, and SELECT are used to access and manage data. The CREATE statement defines a new table, INSERT adds new data to tables, SELECT retrieves data from one or more tables, and constraints like primary keys and foreign keys enforce data integrity. Joins allow querying data across related tables.

Uploaded by

Agenor Gnanzou
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Structured Query Language

Structured Query Language (SQL) is used to access and modify relational databases. A relational database contains a collection of tables without physical pointers. SQL statements like CREATE, INSERT, UPDATE, DELETE, and SELECT are used to access and manage data. The CREATE statement defines a new table, INSERT adds new data to tables, SELECT retrieves data from one or more tables, and constraints like primary keys and foreign keys enforce data integrity. Joins allow querying data across related tables.

Uploaded by

Agenor Gnanzou
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

SQL

(Structured Query Language)

Relational Database Properties


Can be accessed and modified by executing structured query language (SQL) statements Contains a collection of tables with no physical pointers Uses a set of operators

www. H2KINFOSYS.com

Communicating with a RDBMS Using SQL

www. H2KINFOSYS.com

Accessing Database

Application

Database

SQL Tool

www. H2KINFOSYS.com

Database
Oracle MS SQL DB2 MySQL Sybase Postgres PointBase

Etc..

www. H2KINFOSYS.com

SQL Statements

www. H2KINFOSYS.com

SQL
Create Table Update Table Delete Table Insert Data

Select

www. H2KINFOSYS.com

Step I : Creation of a table


To create a table first identify the columns which make up the table with all definitions Tablename should be unique Tablename should start with a alphabet Tablename cannot exceed 30 chars

Syntax of CREATE Statement Create table <tablename> (< Column 1> <Datatype>(Size), (< Column 2> <Datatype>(Size), (< Column 3> <Datatype>(Size), (< Column n> <Datatype>(Size));

www. H2KINFOSYS.com

Step II :Insertion of data


We use the Insert Statement for this job The order of the columns in this command must be the same while creating the table
Syntax of INSERTStatement

You should not skip any column values, type NULL in case you want to omit a column value Char, Varchar and Date values should be enclosed in Single Quotes

Insert into <tablename> values (Col1,Col2,Col3..Col n);

www. H2KINFOSYS.com

SQL
Where clause Group by clause Having clause Joins Sub Queries

www. H2KINFOSYS.com

10

Step III:Retrieval of data


We use the Select Statement for this job You can select all rows and columns from the table or select as you wish You can restrict the data retrieved using a WHERE Clause Operators used in SELECT Relational Operators Logical Operators SQL Operators

www. H2KINFOSYS.com

11

Operators used in SQL


Relational : >, < , = , !=, >= , < = Logical : AND, OR, NOT SQL : LIKE, IN, BETWEEN.. AND

www. H2KINFOSYS.com

12

Functions

www. H2KINFOSYS.com

13

Joins
A Select Statement can be called a Join if, first, the FROM clause names at least two table specifications and second,if the WHERE clause has at least one condition that compares columns from the different tables. Types of Joins: Equi-Join Non-Equi Join Outer-Join Self Join

www. H2KINFOSYS.com

14

Integrity Constraints
Integrity Constraints are the rules with which the contents of a database must comply at all times, and they describe which updates to the database are permitted Types : Table Constraints, Column Constraints Not Null Primary Key Unique Check Foreign Key

www. H2KINFOSYS.com

15

Thank You!

You might also like