My SQL Commands
My SQL Commands
The following SQL statement creates a differential back up of the database "
Ra_AcademyDB ":
Syntax : BACKUP DATABASE Ra_AcademyDB
TO DISK = 'D:\backups\ Ra_AcademyDB.bak'
WITH DIFFERENTIAL;
4. The CREATE TABLE statement is used to create a new table in a database.
Syntax CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g.
varchar, integer, date, etc.).
Example The following example creates a table called "Students_details" that contains
six columns: StudentID, FirstName, LastName, Address, Gender and City:
6. The TRUNCATE TABLE statement is used to delete the data inside a table, but not
the table itself.
Syntax TRUNCATE TABLE table_name;
Example The following SQL statement deletes the existing data from table
"Students_Details":
Syntax : TRUNCATE TABLE Students_Details;
7. The ALTER TABLE statement is used to add, delete, or modify columns in an
existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an
existing table.
Syntax ALTER TABLE - ADD Column Example
ALTER TABLE table_name ALTER TABLE Customers
ADD column_name datatype; ADD Email varchar(255);
Syntax ALTER TABLE - DROP COLUMN Example
ALTER TABLE table_name ALTER TABLE Customers
DROP COLUMN column_name; DROP COLUMN Email;
Syntax ALTER TABLE - RENAME COLUMN Example
ALTER TABLE table_name ALTER TABLE Customers
RENAME COLUMN old_name to RENAME COLUMN Email to PhNo;
new_name;
Syntax ALTER TABLE - ALTER/MODIFY Example
DATATYPE ALTER TABLE Customers
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
MODIFY COLUMN column_name
datatype;