Lesson 4 Creating, Altering, and Deleting Databases and Tables
Lesson 4 Creating, Altering, and Deleting Databases and Tables
USE – Before you can use the USE command, a database must first be created. USE
command is used to select any existing database in the SQL schema. You would need
to select a database where all the operations would be performed.
ALTER – It modifies the structure of an existing database table. This can add up
additional columns, drop existing columns, and even alter the data type of columns
involved in a database table.
DROP – It deletes existing objects from the database. It is used to remove a table,
including its data, indexes, triggers, constraints, and permission specifications
Creating a table •Create Table – It is a DDL language
that allows the creation of a table.
• [table name] – It is the name of the
• CREATE TABLE [table name] table you wish to create.
•( • Column name – It is the name of the
•[column name] [data type] [null | not field.
null], • Data type – It is the type of data that
the column will hold.
•[column name] [data type] [null | not
null], • [null|not null] – It is an optional value
that can be added or not. It enforces a
•[column name] [data type] [null | not column to accept or. not to accept null
null] values. By default, a column can hold
•) null values
Use Command
Syntax: USE [Database_Name]
• Syntax:
• DROP TABLE [table_name];
• Example:
• DROP TABLE student_info