3. Creating and Removing Databases and Tables Flashcards
What is a data type?
A data type defines what type of value a column can contain.
Which statement will produce a new table within a database?
CREATE TABLE tablename;
Which statement will produce a new database?
CREATE DATABASE databasename;
What data type defines that numbers or integers can be used in a column?
int
How do you define the maximum length of letters and numbers for a varchar data type?
varchar(10)
*The ‘10’ can be any number.
True or false: when using the CREATE DATABASE statement on its own, there is data contained inside the database.
False.
What statement would produce a new table AND columns?
CREATE TABLE tablename ( columnname datatype, columnname datatype );
Remember to replace the word ‘datatype’ with the actual datatype to be used for that column.
Which data type allows a column to hold a variable length of letters and numbers (characters) in a column?
varchar
Which statement will remove a table from a database?
DROP TABLE tablename;
Which statement will remove a database and all of its data?
DROP DATABASE databasename;
What do you need to set in a CREATE TABLE statement to allow you to easily enter data later?
The Primary Key e.g.
CREATE TABLE advertisements (ID int PRIMARY KEY, Product varchar, Media varchar, Price int);
If you have set a primary key and data types, what statement would allow you to add values to a particular row?
INSERT INTO table
VALUES (1, ‘text’, 2, ‘text’)