Unit 9 : SQL ( Part 1 ) Flashcards

1
Q

List out 2 broad categories of SQL Functions

A
  1. Data Definition Language ( DDL )
    • Create Database, Tables, Indexs and Views
    • Define access rights to those database objects
  2. Data Manipulation Language ( DML )
    • Commands to insert, update, delete and retireve data within database tables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many words does basic command set has ?

A
  1. Less than 100 words
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Who prescribes a standard SQL?

A
  1. American National Standards Institute ( ANSI )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Will there be several SQL dialects exists ?

A
  1. Yes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List out 2 tasks must be completed before creating a database?

A
  1. Create database structure
  2. Create tables that will hold end-user data
  • RDBMS creates physical files that will hold database
  • RDBMS tends to differ from one to another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is schema?

A
  1. Group of database objects , such as tables and indexes that are related to each other
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does Authentication process through DBMS? ( 2 )

A
  1. Verifies taht only registered users are able to access database
  2. Log on to RDBMS using user id and password created by database administrator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is data type selection is usually dictated by ?

A
  1. Nature of data and by intended use
  • Need to pay close attention to expected use of attributes for sorting and data retrieval purposes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What uses DECIMAL (L,D) for data types?

A
  1. Price
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What use INTEGER for data types?

A
  1. Whole numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

List out 2 data types for Character

A
  1. CHAR(L)
  2. VARCHAR(L) or VARCHAR2(L)
  • Oracle users may use VARCHAR2 as well as VARCHAR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

List out 4 data types for Character

A
  1. NUMBER(L,D)
  2. INTEGER
  3. SMALLINT
  4. DECIMAL(L,D)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List out data types for date

A
  1. DATE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What specification does Primary Key contains ? ( 2 )

A
  1. NOT NULL
  2. UNIQUE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What will RDBMS do after creating Primary Key?

A
  1. Automatically enforce referential integrity for foreign keys
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What symbol should we use when the command sequence ends?

A
  1. Semicolon ( ; )
17
Q

What does NOT NULL constraint ensures?

A
  1. Ensures that column does not accept nulls
18
Q

What does UNIQUE constraint ensures?

A
  1. Ensures that all values in column are unique
19
Q

What does DEFAULT constraint assigns?

A
  1. Assigns value to attribute when a new row is added to table
20
Q

What does CHECK constraint validates

A
  1. Validates data when attribute value is entered
21
Q

List out the commands with Data Manipulation ( 7 )

A
  1. Adding table rows
  2. Saving table changes
  3. Listing table rows
  4. Updating table rows
  5. Restoring table contents
  6. Deleting table rows
  7. Inserting table rows with a select subquery
22
Q

How to insert values ? ( Syntax )

A

INSERT INTO columnname
VALUES ( value1 , value2 , … , valuen )

23
Q

When should we use NULL?

A
  1. NULL for unknown values
24
Q

List out 3 things that lets database save physically on disk

A
  1. Database is closed
  2. Program is closed
  3. COMMIT command is used

COMMIT [WORK]; ( Syntax )
* It will permanently save any changes made to any table in the database

25
Q

What does SELECT used for?

A
  1. Used to list contents of table

SELECT columnlist ( attributes )
FROM tablename;

SELECT * FROM tablename;

26
Q

What does UPDATE do? Can list out the syntax?

A
  1. 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;

27
Q

What does ROLLBACK does?

A
  1. Used to restore database to its previous condition
  2. 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
28
Q

What does DELETE does?

A
  1. Deletes a table row

DELETE FROM tablename
WHERE conditionlist

  • If WHERE condition is not specified, all rows from specified table will be deleted
29
Q

How to select rows with conditional restrictions?

A

SELECT columnlist
FROM tablelist
WHERE conditionlist;

30
Q

What are the symbols for comparison operators ? ( 2 )

A
  1. <>
  2. !=
31
Q

List out 4 rules for arithmetic operators?

A
  1. Perform operations within parentheses
  2. Perform power operations
  3. Perform multiplications and divisions
  4. Perform additions and subtractions
32
Q

What are the symbols for power? ( 2 )

A
  1. **
33
Q

What is between used for?

A
  1. Used to check whether attribute value is within a range
34
Q

What is IS NULL used for?

A
  1. Used to check whether attribute value is null
35
Q

What is LIKE used for?

A
  1. Used to check whether attribute value matches given string pattern
36
Q

What is IN used for?

A
  1. Used to check whether attribute value matches any value within a value list
37
Q

What is EXISTS used for?

A
  1. Used to check if subquery returns any rows