Before creating the database and tables, let’s see what is a server, database and table, and then can proceed with creating them.
1. What is a database?
A database is an application which is used to store and retrieve the data. All the data are stored in the database objects called tables.
2. What is a table?
Table is a database object which actually stores the collection of related data. It consists of rows and columns.
3. What is a server?
A physical computer or a computer program that acts as a centralized resource for other computers in a network is called a server. A server serves all the computers which are connected in a network.
SQL – Create database, table:
SQL – CREATE DATABASE:
- A new SQL database can be created using “CREATE DATABASE” statement. All databases reside on a server. We can create many databases on a server.
CREATE DATABASE database_name;
Where database_name – Actual database name that you want to create.
- When we execute below statement, a new database called STUDENT_DB is created in the server.
CREATE DATABASE STUDENT_DB;
SQL – CREATE TABLE:
- A new SQL table can be created using “CREATE TABLE” statement. All tables reside in a database. We can create many tables in a database.
CREATE TABLE table_name
- When we execute below statement, a new table called ‘student’ is created in the database.
CREATE TABLE student
How to check whether a table exists & the property or description of a table?
- We can use below statement to check whether a table exists or not in a database and the property/description of the table.