Page 251 - PYTHON-12
P. 251
1. Creating Databases
The CREATE DATABASE command is used to create a database in RDBMS.
Syntax for creating a database:
CREATE DATABASE <database_name>;
For example,
CREATE DATABASE school; Creates database with the name school.
When the above-mentioned command gets executed, a database with the name school will be
created on the system.
2. Opening Databases
Once a database has been created, we need to open it to work on it. For this, USE command is
required.
Syntax for opening a database:
USE <database_name>;
For example,
mysql>USE school;
Database changed
3. Removing Databases
To physically remove/delete a database along with all its tables, DROP command is used.
Syntax for removing a database:
DROP DATABASE <database_name>;
For example,
mysql>DROP DATABASE school;
Database deleted
4. Creating a Table
The CREATE TABLE statement is used to create a table in a database. Tables are organized into
rows and columns, and each table must have a name. It is the most extensively used DDL command.
A table must have at least one column.
Syntax for creating a table:
CREATE TABLE <table_name>
(
<column_name1><data_type> [(size)],
Relational Database and SQL
<column_name2><data_type> [(size)],
<column_name3><data_type> [(size)],
....
);
12.21