Create, Drop, Alter

Objectives:
  • To learn different data definition languages
  • To know the syntax of each

There are also SQL queries to create a database or a table, drop a database or a table, or alter the structure of a table.  These queries are not used as frequently as SELECT, UPDATE, DELETE, or INSERT but it would still be good for you to be familiar with these queries.

Most of the time, these queries are generated using a GUI (Graphical User Interface), and where queries are automatically generated by these programs.  As such, developers rarely have to run these directly, but it would still be good to get familiar with these queries so that you know what they look like.

Create database

To create a new database named 'databasename', you simply run the following query:

CREATE DATABASE databasename;

Drop database

To drop or remove a database, you do:

DROP DATABASE databasename;

Create a table

To create a new table, you do:

CREATE TABLE table_name (
    column1 datatype,
    colum...