How to Drop a Database in SQL?

In order to drop an existing database schema, make use of the SQL DROP DATABASE statement.   Syntax of the Drop Statement is as follows: Drop Database DatabaseName; Kindly note that the Database Name should always be unique in RDBMS.   Example: To delete an existing Database named db_1, then the DROP DATABASE Statement will be as follows: Drop Database db_1;   Note that before using the SQL DROP DATABASE statement to

What are the different SQL Datatypes?

While creating Tables, you should make use of the data types. Based on your requirement according to the table columns, choose respective data types.   There are six various types of data types in SQL Server:   Exact Numeric Data Types: DATA TYPE FROM TO int -2,147,483,648 2,147,483,647 smallint -32,768 32,767 bigint -9,223,372,036,854,775,808 9,223,372,036,854,775,807 tinyint 0 255 bit 0 1 numeric -10^38 +1 10^38 -1 decimal -10^38 +1 10^38 -1

How to Create a Table in SQL?

In order to create a basic table, naming the table and defining its fields (columns) and each field’s data type is necessary. Use the SQL Create Table Query to create a new table. Syntax of CREATE TABLE is as follows: Create Table (table_name) ( Column_name1 data_type, Column_name2 data_type, Column_name3 data_type, ………. Column_namen data_type, Primary Key (1 or more columns) );   The Create Table Statement is followed by the unique

How to Create a Database in SQL?

In order to create new SQL Database, make use of the SQL CREATE DATABASE Statement.   Syntax of creating a database: Create Database Database_Name; Kindly note that the Database Name should always be unique in RDBMS.   Example:                To create a new Database named db_1, then the CREATE DATABASE Statement will be as follows:   Create Database db_1; Before you create a database, make sure you have admin rights. On

What are the SQL Constraints?

There are various SQL constraints which are used to enforce rules for the data columns in a table. Constraints assure the accuracy and consistency of the data in database and are used to limit the type of data that can go into a table. There can be column level as well as table level constraints. The constraints applied to one particular column are known as column level constraints whereas the

How to use AND & OR Operators in SQL?

In order to combine multiple conditions and to narrow down data in an SQL statement, the SQL AND and OR operators are used. By using these operators, you can make multiple comparisons with different operators in the same SQL statement. The AND operator displays a record if both the first condition & the second condition are true. The OR operator displays a record if either the first condition or the second condition is true.

How to use Alter Command in SQL?

In order to add, delete or modify any columns in any existing tables, the SQL ALTER TABLE command is used. You can also use Alter table Statement to add and drop different constraints of an existing table. The basic Syntaxes are as follows:   ALTER TABLE to add a new column in an existing table: Alter Table table_name ADD column_name datatype;   ALTER TABLE to DROP COLUMN in an existing table: Alter table table_name DROP

How to create Views in SQL?

A virtual table is known as view. A view contains rows and columns, just like an actual table. The fields in a view are fields from one or more real tables in the database. To present the data as if the data is coming from a single table, SQL functions like WHERE and JOIN statements can be added. Views are created using the CREATE VIEW statement. Views can be created from a

How to insert data in tables using SQL?

To insert records into the table using MySQL, INSERT INTO statement is used. What is MySQL insert? In order to enter or insert information into the MySql table, MySQL Insert is used. To do so, one has to create a table with column(s) of the same type as that of the content one would like to insert. Thus, one cannot insert word articles in a column which accepts only integers. How to Add Data

What is a Distinct Keyword in SQL?

There may be duplicate values or records in a table. In order to eliminate those duplicate values and if you want to fetch or view only the unique (distinct) values, the SQL DISTINCT keyword is used in combination with SELECT statement. The Distinct keyword will return only the on-duplicate or different values. The syntax is as follows: Select Distinct column_name1, column_name2, …., column_namen From (table_name); Example: Consider the Students table having the