The CREATE DATABASE statement is used to create a database.
Syntax:
CREATE DATABASE database_name |
Example:
Now we want to create a database called "my_Database", We use the following CREATE DATABASE statement: CREATE DATABASE my_Database |
SQL ALTER DATABASE
For More Details follow these links:
http://msdn.microsoft.com/en-us/library/ms174269.aspx
http://msdn.microsoft.com/en-us/library/aa275464(v=sql.80).aspx
SQL DROP DATABASE
The DROP DATABASE statement is used to delete a database.Example:
DROP DATABASE database_name |
SQL CREATE TABLE
The CREATE TABLE statement is used to create a table in a database.Syntax:
CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, .... ) |
SQL CREATE TABLE Example
Now we want to create a table called "Persons" that contains five columns: P_Id, LastName, FirstName, Address, and City.We use the following CREATE TABLE statement:
CREATE TABLE Persons ( P_Id int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ) |
Note: You can see the table created by select * from Persons Statement.
The empty "Persons" table will now look like this:
P_Id | LastName | FirstName | Address | City |
| | | | |
SQL DROP TABLE Statement
The DROP TABLE statement is used to delete a table.Syntex:
DROP TABLE table_name |
Example:
DROP TABLE Persons |
SQL TRUNCATE TABLE Statement
What if we only want to delete the data inside the table, and not the table itself?Then, use the TRUNCATE TABLE statement:
Syntex:
TRUNCATE TABLE table_name |
Example:
TRUNCATE TABLE Persons |
No comments:
Post a Comment