Lesson 1: MySQL Basic Commands Flashcards
Command to create a database.
CREATE DATABASE databaseName;
Command to create a table.
CREATE TABLE tableName (columnName dataType (length), ….);
Data Type for id.
INT
Datatype for name
VARCHAR
Data type for date
DATE
Data type for date and time
TIMESTAMP
Data type for decimal numbers
DECIMAL (whole, decimal)
Data type for images
BLOB
Command to schedule task
CREATE TRIGGER
Command to add a column to table
ALTER TABLE tableName ADD columnName dataType (length);
Command to change the table’s name.
ALTER TABLE oldTableName TO newTableName;
Command to change column’s name.
ALTER TABLE tableName CHANGE oldColName newColName dataType (length);
Command to remove a column.
ALTER TABLE tableName DROP COLUMN columnName;
Command to delete all data.
TRUNCATE TABLE tableName;
Command to delete structure and data of table.
DROP TABLE tableName;