Loading video...
Creating Databases & Tables
- A database is created using the
CREATE DATABASESQL command:CREATE DATABASE dbName;
- MySQL provides the following non-SQL commands:
SHOW DATABASES– lists all of the databases on a MySQL serverUSE– selects a particular database on a MySQL server to use and to apply future commands to
- SQL defines the
CREATE TABLEcommand for creating database tables. It accepts a comma-delimited list of column definitions between parentheses and has the following syntax:CREATE TABLE tblName
(
colName1 dataType1 colAttr1,);
colName2 dataType2 colAttr2,
… - SQL Numeric Data Types:
INT– integer data typeINT UNSIGNED– positive integer data typeDECIMAL(M, D)– floating point number withMdigits,Ddigits after the decimal point
- SQL String Data Types:
CHAR(M)– fixed-length string ofMcharactersVARCHAR(M)– variable-length string up toMcharacters in lengthTEXT– large amounts of string data
- Each column in a table can have attributes set that affect the functionality of the column.
- The
PRIMARY KEYattribute denotes a column as the primary key for the table.- Only one column can have the
PRIMARY KEYattribute.
- Only one column can have the
- The
AUTO_INCREMENTattribute denotes that MySQL should automatically generate the value for the column for each row by incrementing the largest column value at the time a row is inserted by one.- This only can apply to integer or floating-point columns
- The
SHOW TABLEScommand can be used to list all of the tables in a particular database. - The
DESCRIBEutility statement can be used to see the structure of a table. - Additional Resources:
Creating Databases & Tables
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview