SQL Flashcards Preview

Paper 2 - Computer Science > SQL > Flashcards

Flashcards in SQL Deck (19)
Loading flashcards...
1

What does sql stand for?

Structured Query Language

2

What are the advantages of using SQL?

It's easy to learn and use (as it's a declarative language)

3

What are the 5 main SQL commands and what are the used for?

CREATE - used for creating tables
SELECT - used for retrieving data from a table
UPDATE - used for changing an attribute in an existing record
INSERT - used for
DELETE - used for removing records from a table

4

What is the format for a SELECT command?

SELECT attributes FROM table WHERE condition ORDER BY asc/desc

5

What is the format for a UPDATE command?

UPDATE table (attributes) SET new values WHERE = condition

6

What is the format for a DELETE command?

DELETE attributes FROM table WHERE condition

7

What is the format for a INSERT command that inserts values into all columns?

INSERT INTO table VALUES (value1, value2, …)

8

What is the format for a INSERT command that inserts values into specific columns?

INSERT INTO tablename (column1, column2) VALUES (value1, value2, …)

9

What does SELECT * FROM .... mean and what is the special name for it?

-It means select all the attributes from the database that apply to the condition.
-The asterix (select all) is called a wildcard

10

What is the format for a CREATE command that inserts values into specific columns?

CREATE TABLE ( VARCHAR(225), VARCHAR(255),
YEAR, PRIMARY KEY ( , ))

11

How is a fixed length string data type represented?

CHAR(size) - A string with the number of
characters specified by size

12

How is a variable length string data type represented?

VARCHAR(size) - A string with any number of characters up to the number specified by size

13

How is a Integer data type represented?

INT(size) - Stores a whole number using the number of bits specified by size

14

How is a Number with fractional part data type represented?

FLOAT(size, precision) - A number stored using the number of bits specified by size with digits after the decimal point up to the number specified by precision

15

How is a Date data type represented?

DATE - A date in the format YYYY-MM-DD

16

How is a Date and time data type represented?

DATETIME - A date and time combined in the format YYYY-MM-DD HH:MM:SS

17

How is a Time data type represented?

TIME - A time in the format HH:MM:SS

18

How is a Year data type represented?

YEAR - A year in one of the two formats YY or YYYY

19

What is the format for an ALTER command?

To add a column: ALTER TABLE Employee ADD Department VARCHAR(10)

To delete a column: ALTER TABLE Employee DROP COLUMN HireDate

To change a column data type: ALTER TABLE Employee MODIFY COLUMN EmpName VARCHAR(30) NOT NULL