Finals Lecture 2: SQL Flashcards
SQL stands for ___.
Structured Query Language
It is used for storing and managing data in Relational Database Management System (RDBMS).
SQL
What is SQL used for?
It is used for storing and managing data in Relational Database Management System (RDBMS).
RDBMS
Relational Database Management System
It is a standard language for Relational Database System.
SQL
SQL enables user to…
create, read, update and delete relational databases and tables.
All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use ___ as their standard database language.
SQL
SQL allows users to ___ the database in a number of ways, using English-like statements.
query
Structure query language is ___. Generally, keywords of SQL are written in uppercase.
not case sensitive
Statements of SQL are ___. We can use a ___ on one or ___.
dependent on text lines; single SQL statement; multiple text line
Using the ___, you can perform most of the actions in a database.
SQL statements
SQL depends on ___ and ___.
tuple relational calculus; relational algebra
SQL follows the following rules:
- is not case sensitive but is usually written in uppercase
- dependent on text lines
- uses sql statements to perform actions in a db
- depends on tuple relational calculus and relational algebra
When an ___ is executing for any RDBMS, then the system figure out the best way to ___ and the ___ determines that how to interpret the task.
SQL command; carry out the request; SQL engine
In the process, various components are included. These components can be…
optimization Engine, Query engine, Query dispatcher, classic, etc.
All the non-SQL queries are handled by the ___, but SQL query engine won’t ___.
classic query engine; handle logical files
What is the SQL Process
When an SQL command is submitted:
system»_space; figures out the best way to carry out the request
SQL engine» determines how to interpret the task
classic query engine»_space; handles non-SQL queries
SQL query engine»_space; handles SQL queries but not logical files
Graphical framework of SQL Process
SQL Query»_space; Query Language Processor -> [Parser + Optimizer]»_space; DBMS Engine -> [File Manager + Transaction Manager]»_space; Physical Database
What is Advantages of SQL?
- High speed
- No coding needed
- Well defined standards
- Portability
- Interactive language
- Multiple data view
What is SQL Datatype?
SQL Datatype is used to define the values that a column can contain. Every column is required to have a name and data type in the database table
Enlist the SQL datatypes
Binary
Numeric
Extract Numeric
String
Date
SQL commands are ___. It is used to communicate with the database. It is also used to perform specific tasks, functions, and queries of data.
instructions;
It is used to communicate with the database.
SQL commands
It is also used to perform specific tasks, functions, and queries of data.
SQL commands
SQL can perform various tasks like: (5)
create a table, add data to tables, drop the table, modify the table, set permission for user
Types of SQL Commands
DDL, DML, DCL, TCL, DQL
DDL
Data Definition Language
DML
Data Manipulation Language
DCL
Data Control Language
TCL
Transaction Control Language
DQL
Data Query Language
Commands under DDL
Create, Drop, Alter, Truncate
Commands under DML
Insert, Update, Delete
Commands under DCL
Grant, Revoke
Commands under TCL
Commit, Rollback, Save point
Commands under DQL
Select
SQL command that changes the structure of the table like creating a table, deleting a table, altering a table, etc.
DDL, Data Definition Language
DDL command, is used to create a new table in the database.
CREATE
Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,….]);
Example:
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);
DDL command, is used to delete both the structure and record stored in the table.
DROP
Syntax:
DROP TABLE ;
Example:
DROP TABLE EMPLOYEE;
DDL command, is used to alter the structure of the database. This change could be either to modify the characteristics of an existing attribute or probably to add a new attribute.
ALTER
Syntax:
ALTER TABLE table_name ADD column_name COLUMN-definition;
ALTER TABLE MODIFY(COLUMN DEFINITION….);
Example:
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
DDL command, is used to delete all the rows from the table and free the space containing the table.
TRUNCATE
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE;
___ are used to modify the database. It is responsible for all form of CHANGES in the database.
DML, Data Manipulation Language
The command of DML is ___ that means it can’t permanently save all the changes in the database. They can be ___.
not auto-committed; rollback
DML command, the ___ is a SQL query. It is used to insert data into the row of a table.
INSERT statement;
INSERT
Syntax:
INSERT INTO TABLE_NAME (col1, col2, col3,…. col N) VALUES (value1, value2, value3, …. valueN);
OR
INSERT INTO TABLE_NAME VALUES (value1, value2, value3, …. valueN);
Example:
INSERT INTO XYZ (Author, Subject) VALUES (“Sonoo”, “DBMS”);
DML command, is used to update or modify the value of a column in the table.
UPDATE
Syntax:
UPDATE table_name SET [column_name1= value1,…column_nameN = valueN] [WHERE CONDITION]
Example:
UPDATE students SET User_Name = ‘Sonoo’ WHERE Student_Id = ‘3’
___ are used to GRANT and TAKE BACK authority from any database user.
DCL commands
DCL command, is used to give user access privileges to a database.
GRANT
Example:
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
DCL command, is used to take back permissions from the user.
REVOKE
Example:
REVOKE SELECT, UPDATE ON MY_TABLE FROM USER 1, USER 2;
___ can only use with DML commands like INSERT, DELETE and UPDATE only
TCL commands
These operations are automatically committed in the database that’s why they cannot be used while creating tables or dropping them.
TCL, transaction control language