Creating SQL Database In 2 Minutes
A database is a collection of tables that contains some specific types of structured data. These databases can be easily created with the help of SQL. Then SQL commands also known as SQL queries are used to retrieve the required data or information from it.
Now, let’s see how we can create, drop backup and create tables in a database using SQL.
1. Create Database:
Creating a new SQL database is one of the simplest tasks. Simply write one CREATE statement and we are done with it.
Syntax:
CREATE DATABASE database_name;
2. Drop Database:
We can drop the existing database by using the DROP statement the syntax for which is as follows:
Syntax:
DROP DATABASE database_name;
3. Backup Database:
To create a backup of a database we have to use a BACKUP statement and provide it with a storage location where you need to store the backup of the database using the syntax as shown below:
Syntax:
BACKUP DATABASE database_name
TO DISK = ‘filepath’;
Here the file path refers to the location on the PC where you want to store the backup of the database.
4. Creating tables in a database:
After creating a database, we can create tables in a specific database by adding a database name in the CREATE TABLE statement as follows:
Syntax:
CREATE TABLE database_name.table_name (column_name1 datatype_1, column_name2 datatype2, ………)
Conclusion:
In this we learned about how to create, drop, backup and create tables in a database using SQL. For more such upcoming content related to Python, Machine Learning, Data Science and Front-end development follow Chirag Rathi! The link to some of the best online resources for SQL is provided at the end.
Happy Learning!😊
Reach me🤙:
- Visit my portfolio website at chiragrathi.me