3. Creating and Removing Databases and Tables Flashcards

1
Q

What is a data type?

A

A data type defines what type of value a column can contain.

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

Which statement will produce a new table within a database?

A

CREATE TABLE tablename;

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

Which statement will produce a new database?

A

CREATE DATABASE databasename;

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

What data type defines that numbers or integers can be used in a column?

A

int

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

How do you define the maximum length of letters and numbers for a varchar data type?

A

varchar(10)

*The ‘10’ can be any number.

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

True or false: when using the CREATE DATABASE statement on its own, there is data contained inside the database.

A

False.

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

What statement would produce a new table AND columns?

A
CREATE TABLE tablename
(
columnname datatype,
columnname datatype
);

Remember to replace the word ‘datatype’ with the actual datatype to be used for that column.

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

Which data type allows a column to hold a variable length of letters and numbers (characters) in a column?

A

varchar

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

Which statement will remove a table from a database?

A

DROP TABLE tablename;

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

Which statement will remove a database and all of its data?

A

DROP DATABASE databasename;

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

What do you need to set in a CREATE TABLE statement to allow you to easily enter data later?

A

The Primary Key e.g.

CREATE TABLE advertisements
(ID int PRIMARY KEY,
Product varchar,
Media varchar,
Price int);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

If you have set a primary key and data types, what statement would allow you to add values to a particular row?

A

INSERT INTO table

VALUES (1, ‘text’, 2, ‘text’)

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