MySQL Quick Reference Guide – Basic Commands


Quick Reference for MySQL

mysql_logoWhen I’m looking around the net for quick reference of MySQL syntax, I always have to pick through a bunch of verbiage to find what I need. I’m going to get right to the point of this post and skip the multitude of text.

Basic MySQL Commands

Create Table with Primary Key:
CREATE TABLE TableName (TableID INT(32) NOT NULL PRIMARY KEY AUTO_INCREMENT);

Add Column:
ALTER TABLE TableName ADD ColumnName TYPE(LIMIT);

Add Column with MUL Key
ALTER TABLE TableName ADD ColumnName INT(32) NOT NULL, ADD KEY (ColumnName)

Drop Column:
ALTER TABLE TableName DROP ColumnName;

Modify Column:
ALTER TABLE TableName MODIFY DateColumn DateTime NOT NULL DEFAULT ”;

Delete All Rows from Table:
DELETE FROM TableName;

Truncate Table Data:
TRUNCATE TABLE TableName;

Delete Entire Table:
DROP TABLE TableName;

Reset Auto Increment:
ALTER TABLE TableName AUTO_INCREMENT = 1;

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>