L23 - SQL 1 Flashcards

1
Q

What is SQL?

A
  • Main language for relational DBMS
  • Declarative - specification on what you require
  • Free format
  • Consist of english words
  • Used by a range of users
  • 2 components
    • Data Definition Language (DDL)
      • Define DB structure
      • Data Access Control
    • Data Manipulation Language (DML)
      • Retrieve and update data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the objective of SQL?

A
  • Database Language should
    • Create database and table structure
    • Basic operations - add, amend and remove
    • Simple and complex queries
  • Minimal user effort
  • Portable to a recognised standard ISO
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you write SQL commands?

A
  • Pool of reserved words + User defined words
    • Reserved words (UPDATE, SELECT)
      • Fixed part of SQL
      • Spelling is required
      • Cannot be split across lines
    • User Defined Words
      • Made up by the user
      • Rep names of various database objects
        • Tables, columns and views
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are literals?

A
  • Used in SQL statements
  • Non-numeric literals are enclosed in single quotes
  • Numeric literals are not enclosed in quotes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the SELECT statment?

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

What is the NULL search condition?

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

What are calculated fields?

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

What is the WHERE calause

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

What is pattern matching?

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

How do you sort the result table?

A
  • Usually rows are presented in no order
  • ORDER BY allows rows to be sorted
    • By 1+ specified columns
    • Use ASC or DESC keyword
    • Add more minoring clause by adding a comma
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you use HAVING?

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

Wha tis a modification statment?

A
  • INSERT - adds new rows of data
  • UPDATE - modifies existing data in a table
  • DELETE - removes rows of data from a table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the INSERT statment?

A
  • Data to be inserted must be in order of the columns
  • Must be compatible with the data type of corresponding column
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the UPDATE STATMENT?

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

What is the DELETE statment?

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