SQL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does sql stand for?

A

Structured Query Language

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

What are the advantages of using SQL?

A

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

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

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

A

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

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

What is the format for a SELECT command?

A

SELECT attributes FROM table WHERE condition ORDER BY asc/desc

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

What is the format for a UPDATE command?

A

UPDATE table (attributes) SET new values WHERE = condition

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

What is the format for a DELETE command?

A

DELETE attributes FROM table WHERE condition

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

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

A

INSERT INTO table VALUES (value1, value2, …)

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

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

A

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

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

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

A
  • It means select all the attributes from the database that apply to the condition.
  • The asterix (select all) is called a wildcard
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A
CREATE TABLE  ( VARCHAR(225),   VARCHAR(255), 
  YEAR, PRIMARY KEY ( , ))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is a fixed length string data type represented?

A

CHAR(size) - A string with the number of

characters specified by size

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

How is a variable length string data type represented?

A

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

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

How is a Integer data type represented?

A

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

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

How is a Number with fractional part data type represented?

A

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

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

How is a Date data type represented?

A

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

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

How is a Date and time data type represented?

A

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

17
Q

How is a Time data type represented?

A

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

18
Q

How is a Year data type represented?

A

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

19
Q

What is the format for an ALTER command?

A

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