CREATE DATABASE databasename;
Database
Create
Syntax:
Drop
Syntax:
DROP DATABASE databasename;
Backup
Is used in SQL Server to create a full back up of an existing SQL database
BACKUP DATABASE databasename= 'filepath'; TO DISK
Differential
To only back up the parts of the database that have changed since the last full backup, use WITH DIFFERENTIAL
BACKUP DATABASE databasename= 'filepath'
TO DISK WITH DIFFERENTIAL;
Dump > Backup
Using the CLI we can backup all the steps and data we need to recreated the db using SQL. This will include all the statements to create the exact db from scratch
- Here below we have user = root
- Password: if required
- It will create a backup.sql file in the same directory where the db: employees is located
-u root employees > employeesbackup.sql mysqldump
Backup > Restore
Here using the same command in reverse would restore an entire db from the backup file
--host=mysql -- port=3306 --user=root --password employees < employeesbackup.sql
mysql
# from inside a mysql command prompt
> source employeesbackup.sql mysql