Unit 9 : SQL ( Part 1 ) Flashcards
List out 2 broad categories of SQL Functions
- Data Definition Language ( DDL )
- Create Database, Tables, Indexs and Views
- Define access rights to those database objects
- Data Manipulation Language ( DML )
- Commands to insert, update, delete and retireve data within database tables
How many words does basic command set has ?
- Less than 100 words
Who prescribes a standard SQL?
- American National Standards Institute ( ANSI )
Will there be several SQL dialects exists ?
- Yes
List out 2 tasks must be completed before creating a database?
- Create database structure
- Create tables that will hold end-user data
- RDBMS creates physical files that will hold database
- RDBMS tends to differ from one to another
What is schema?
- Group of database objects , such as tables and indexes that are related to each other
How does Authentication process through DBMS? ( 2 )
- Verifies taht only registered users are able to access database
- Log on to RDBMS using user id and password created by database administrator
What is data type selection is usually dictated by ?
- Nature of data and by intended use
- Need to pay close attention to expected use of attributes for sorting and data retrieval purposes
What uses DECIMAL (L,D) for data types?
- Price
What use INTEGER for data types?
- Whole numbers
List out 2 data types for Character
- CHAR(L)
- VARCHAR(L) or VARCHAR2(L)
- Oracle users may use VARCHAR2 as well as VARCHAR
List out 4 data types for Character
- NUMBER(L,D)
- INTEGER
- SMALLINT
- DECIMAL(L,D)
List out data types for date
- DATE
What specification does Primary Key contains ? ( 2 )
- NOT NULL
- UNIQUE
What will RDBMS do after creating Primary Key?
- Automatically enforce referential integrity for foreign keys
What symbol should we use when the command sequence ends?
- Semicolon ( ; )
What does NOT NULL constraint ensures?
- Ensures that column does not accept nulls
What does UNIQUE constraint ensures?
- Ensures that all values in column are unique
What does DEFAULT constraint assigns?
- Assigns value to attribute when a new row is added to table
What does CHECK constraint validates
- Validates data when attribute value is entered
List out the commands with Data Manipulation ( 7 )
- Adding table rows
- Saving table changes
- Listing table rows
- Updating table rows
- Restoring table contents
- Deleting table rows
- Inserting table rows with a select subquery
How to insert values ? ( Syntax )
INSERT INTO columnname
VALUES ( value1 , value2 , … , valuen )
When should we use NULL?
- NULL for unknown values
List out 3 things that lets database save physically on disk
- Database is closed
- Program is closed
- COMMIT command is used
COMMIT [WORK]; ( Syntax )
* It will permanently save any changes made to any table in the database
What does SELECT used for?
- Used to list contents of table
SELECT columnlist ( attributes )
FROM tablename;
SELECT * FROM tablename;
What does UPDATE do? Can list out the syntax?
- Modify data in table
UPDATE tablename
SET columnname = expression
WHERE conditionlist;
- If more than one attribute is to be updated in row, separate corrections with commas
UPDATE tablename
SET columnname = expression , columnname = expression
WHERE conditionlist;
What does ROLLBACK does?
- Used to restore database to its previous condition
- Only applicable if COMMIT command has not been used to permanently store changes in database
- ROLLBACK
- Both COMMIT and ROLLBACK only work with data manipulation commands that are used to add, modify, or delete table rows
What does DELETE does?
- Deletes a table row
DELETE FROM tablename
WHERE conditionlist
- If WHERE condition is not specified, all rows from specified table will be deleted
How to select rows with conditional restrictions?
SELECT columnlist
FROM tablelist
WHERE conditionlist;
What are the symbols for comparison operators ? ( 2 )
- <>
- !=
List out 4 rules for arithmetic operators?
- Perform operations within parentheses
- Perform power operations
- Perform multiplications and divisions
- Perform additions and subtractions
What are the symbols for power? ( 2 )
- **
What is between used for?
- Used to check whether attribute value is within a range
What is IS NULL used for?
- Used to check whether attribute value is null
What is LIKE used for?
- Used to check whether attribute value matches given string pattern
What is IN used for?
- Used to check whether attribute value matches any value within a value list
What is EXISTS used for?
- Used to check if subquery returns any rows