Basic SQL commands to manage your databases:
➤ To list all the database, tables and objectives:
SELECT * FROM sys.tables
SELECT * FROM sys.databases
SELECT * FROM sys.objects
➤ To create database:
➤ To create table:
CREATE TABLE Name_of_the_Table (Name_of_the_FIRST_column data_specification Name_of_the_SECOND_column data_specification
... );
➤ To insert data to a specific columns:
INSERT INTO Table_Name (Column_Name_1, Column_Name_2) VALUES ("Value_1", Value_2);
➤ To update a data:
UPDATE Table_Name SET Column_Name= New_Data WHERE Row_Number = Number_of_the_Row;
➤ To delete a data:
DELETE FROM Table_Name WHERE Row_Number = Number_of_the_Row;
➤ To list all the database, tables and objectives:
SELECT * FROM sys.tables
SELECT * FROM sys.databases
SELECT * FROM sys.objects
➤ To create database:
CREATE DATABASE Name_of_the_Database;
➤ To use the database we created:
USE Name_of_the_Database;
USE Name_of_the_Database;
➤ To create table:
CREATE TABLE Name_of_the_Table (Name_of_the_FIRST_column data_specification Name_of_the_SECOND_column data_specification
... );
➤ To insert data to a specific columns:
INSERT INTO Table_Name (Column_Name_1, Column_Name_2) VALUES ("Value_1", Value_2);
➤ To update a data:
UPDATE Table_Name SET Column_Name= New_Data WHERE Row_Number = Number_of_the_Row;
➤ To delete a data:
DELETE FROM Table_Name WHERE Row_Number = Number_of_the_Row;
➤ To delete a database:
DROP DATABASE Database_Name;
If you take error messsage because of your database is not empty, you need to delete the tables inside first:
DROP TABLE Table_Name;
Comments
Post a Comment