Experiment No. - 9, 10 Aim Theory::: To Study SQL Basics
Experiment No. - 9, 10 Aim Theory::: To Study SQL Basics
Experiment No. - 9, 10 Aim Theory::: To Study SQL Basics
9, 10
Aim: To Study SQL Basics.
Theory:
SQL is a standard language for accessing and manipulating databases.
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL is an ANSI (American National Standards Institute) standard
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.
The DDL part of SQL permits database tables to be created or deleted. It also defines indexes (keys),
specifies links between tables, and imposes constraints between tables. The most important DDL
statements in SQL are:
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
The data type specifies what type of data the column can hold.
In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes
you will want to list only the different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.
The WHERE clause is used to extract only those records that fulfill a specified criterion.
The AND operator displays a record if both the first condition and the second condition are true.
The OR operator displays a record if either the first condition or the second condition is true.
SQL> select Name from students
2 where age=30 and id=1;
NAME
-------------------------------------------------------------------------------sana
SQL> select Name from students
Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or
records that should be updated. If you omit the WHERE clause, all records will be updated!
SQL> update students
2 set branch='Mech'
3 where name='Jhon';
1 row updated.
SQL> select * from students;
ID
NAME
BRANCH
AGE
-----------------------------------------------------------------------------------------1
sana
computer
30
2
seema
IT
30
3
Jhon
Mech
28
----------------------- -------------------------- ---------------------------------SQL> insert into students
2 values(4,'Ram','Mech',25);
1 row created.
SQL> select * from students;
ID
NAME
BRANCH
AGE
-----------------------------------------------------------------------------------------1
sana
computer
30
2
seema
IT
30
3
Jhon
Mech
28
4
Ram
Mech
25
----------------------- -------------------------- ----------------------------------
AGE
-----------------------------------------------------------------------------------------1
sana
computer
30
2
seema
IT
30
3
Jhon
Mech
28
----------------------- -------------------------- ----------------------------------