A database is described as an organized way of collection of DATA. It is the collection of schemes, tables, queries, reports, views and other objects.
Syntax:CREATE DATABASE DatabaseName
Structured Query Language, also known as SQL, is a programming language designed for managing Relational Database Management Systems (RDBMSs). SQL is an International Organization for Standardization (ISO) standard.
In RDBMS all the data is stored in tables with each table consisting of rows and columns.
It is referred as Relation Database Management Systems (RDBMS).
How to create a table in SQL?
Create table TableName
How to delete a table in SQL Server?
Delete Data Record from Database Table and deleting an existing table by the following method:
To delete all table records of a table:
How to update a database table using SQL?
To update an existing Table we use SQL Command UPDATE: It will update the records as per user defined query/need.
Update TableName SET ColumnName = NewData where Condition
What is a primary key of a database?
A table column with this constraint is called the key column for the table. This constraint helps the table to make sure that the value is not repeated and also that there are no null entries.
A table can have only one Primary key. Multiple columns can participate on the primary key.
What is a foreign key of a database?
To define the relationship between two tables (one is called parent and the other one is the child table) connected by columns, a foreign key constraint is used. In this constraint the values of the child table must appear in the parent table, which means that for a foreign key, one table should point to a Primary Key in another table. A table can have multiple foreign keys and each foreign key can have a different referenced table.
What is database normalization?
Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships among them. Normalization is a bottom-up technique for database design.
Types of Normalization:
1-First Normal Form (1NF)
2-Second Normal Form (2NF)
3-Third Normal Form (3NF)
4-Boyce-Codd Normal Form (BCNF)
5-4th Normal Form
6-5th Normal Form
7-6th Normal Form
What is a stored procedure?
A Stored Procedure is a collection or a group of T-SQL statements. Stored Procedures are a precompiled set of one or more statements that are stored together in the database. They reduce the network load because of the precompilation. We can create a Stored Procedure using the "Create proc" statement.
Why we use Stored Procedure?
There are several reasons to use a Stored Procedure. They are a network load reducer and decrease execution time because they are precompiled. The most important use of a Stored Procedure is for security purposes. They can restrict SQL Injection. We can avoid SQL injection by use of a Stored Procedure.
How to create a Stored Procedure?
CREATE PROCEDURE spEmployee
SELECT EmployeeId, Name, Gender, DepartmentName
How Many Type of Triggers?
There are two types of Triggers:
They fire in response to DDL (Data Definition Language) command events that start with Create, Alter and Drop like Create_table, Create_view, drop_table, Drop_view and Alter_table.
Code of DDL Triggers:
create trigger saftey
create_table, alter_table, drop_table
print 'you can not create ,drop and alter table in this database'
They fire in response to DML (Data Manipulation Language) command events that start with Insert, Update and Delete like insert_table, Update_view and Delete_table.
Code of DML Trigger:
create trigger deep
insert, update, delete
print 'you can notinsert,update and delete this table i'
What is a view in the database?
A View is nothing but a select query with a name given to it or we can simply say a view is a Named Query.
CREATE VIEW view_name AS
How many types of Index are there in Sql Server?
There are Two Types of Index in Microsoft SQL Server:
2-Non Clustered Index
A Clustered Index sorts and stores the data in the table based on keys. A Clustered Index can be defined only once per table in the SQL Server Database, because the data rows can be sorted in only one order. Text, nText and Image data are not allowed as a Clustered index.
What is Non-Clustered Index?
Non Clustered Indexes or simply indexes are created outside of the table. SQL Server supports 999 Non-Clustered per table and each Non-Clustered can have up to 1023 columns. A Non-Clustered Index does not support the Text, nText and Image data types.