SQL COMMANDS Flashcards
DDL
DATA DEFINITION LANGUAGE
These SQL commands are used for creating, modifying, and dropping the structure of database objects
SQL
STRUCTURED QUERY LANGUAGE
CREATE
It creates a new table, a view of a table.
DDL
ALTER
It modifies the existing table.
DDL
TRUNCATE
DROP
It deletes the entire table or other objects in the database.
DDL
RENAME
DDL
DML
DATA MANIPULATION LANGUAGE
These SQL commands are used for storing, retrieving, modifying, and deleting data.
SELECT
It extracts certain records from one or more table
DML COMMAND
INSERT
It creates a record in the existing table.
DML COMMAND
UPDATE
It modifies the existing record of the table.
DML COMMAND
DELETE
It deletes the records in the table and even delete the complete table.
DML COMMAND
TCL
TRANSACTION CONTROL LANGUAGE
These SQL commands are used for managing changes affecting the data
COMMIT
ROLLBACK
SAVEPOINT
DCL
DATA CONTROL LANGUAGE
These SQL commands are used for providing security to database objects.
WHERE CLAUSE
The condition you provide in the WHERE clause filters the rows retrieved from the table and gives you only those rows which you expected to see. WHERE clause can be used along with SELECT, DELETE, UPDATE statements.
SELECT COMMAND
SQL SELECT statement is used to query or retrieve data from a table in the database
SQL OPERATOR TYPES
COMPARISON AND LOGICAL
COMPARISON OPERATORS
SYMBOLS
= EQUAL TO
<>, != NOT EQUAL TO
< LESS THAN
> GREATER THAN
>= GREATER THAN OR EQUAL TO
<= LESS THAN OR EQUAL TO
LOGICAL OPERATORS
AND
OR
NOT
SQL OPERATORS USED WITH WHAT CLAUSES
MAINLY:
WHERE AND HAVING
GROUP BY CLAUSE
The SQL GROUP BY Clause is used along with the group functions to retrieve data grouped according to one or more columns.
SQL WILDCARDS
_
%
%
SUBSTITUTE FOR ZERO OR MORE CHARACTERS
_
SUBSTITUTE FOR A SINGLE CHARACTER
ALTER TABLE
ADD COLUMN
ALTER TABLE table_name ADD column_name datatype;
==
ALTER TABLE employee ADD experience number(3);
ALTER TABLE DROP COLUMN
ALTER TABLE table_name DROP column_name;
==
ALTER TABLE employee DROP location;
ALTER TABLE MODIFY COLUMN
ALTER TABLE table_name MODIFY column_name datatype;
==
ALTER TABLE employee MODIFY salary number(15,2);
RENAME COMMAND
RENAME old_table_name To new_table_name;
==
RENAME employee TO my_emloyee;
STRING DATA TYPES
CHAR(X)
VAR(CHARX)
TEXT
TEXT DATA TYPE
This type is used to store long textual information.
VARCHAR(X) DATA TYPE
This type got its name from Varying Characters. This data type doesn’t pad unnecessary space. Here x is the number of characters to store
CHAR(X)
This data type is space padded to fill the number of characters specified. Here x is the number of characters to store.
DATE TIME DATA TYPES
DATE
TIME
DATE
This data type is used to store only date information.