DDL OPERATIONS: The various DDL commands are CREATE, ALTER and DROP. Let us learn about each DDL Command one by one with examples. CREATE Statement: The CREATE statement in SQL is used to create the database and the database objects like Tables, Views, Sequences, etc. Let us see how a database and table are created in SQL. Creating a database in SQL: Syntax: CREATE DATABASE DatabaseName; Example: CREATE DATABASE Demos; On executing this query, a database named "Demos" is created. Creating Table in SQL: Database is a collection of related tables and other objects. This implies that a table is a part of the database. Now, we have created the "Demos" database. And, we need to create a "Students" table in this database. By default, the master database is selected. Select Demos database from the dropdown list or alternatively you can use the following command: Use Demos; This ...
Popular posts from this blog
Transactions in SQL Server: Understanding Transactions in SQL Server Transactions are essential for maintaining data integrity, both for multiple related operations and when multiple users that update the database concurrently. What a transaction is When to use transactions Understanding ACID properties Design of a Transaction Transaction state Specifying transaction boundaries T-SQL statements allowed in a transaction Local transactions in SQL Server 2012 Distributed transactions in SQL Server 2012 Guidelines to code efficient transactions How to code transactions What Is a Transaction? A transaction is a set of operations performed so all operations are guaranteed to succeed or fail as one unit. Transaction is all or none A common example of a transaction is the process of transferring money from a checking account to a savings account. This involves two operations: Deducting money from the current account and Adding it to the savings...
Types of keys in DBMS What is Key? Keys are fields in a table which participate in below activities in RDBMS systems: To create relationships between two tables. To maintain uniqueness in a table. To keep consistent and valid data in database. Might help in fast data retrieval by facilitating indexes on column(s). SQL Server supports various types of keys, which are listed below: Candidate Key Primary Key Unique Key Alternate Key Composite Key Super Key Foreign Key Before discussing each type in brief, have a look on the below image used as an an example to define types of keys. Lets discuss each type in detail: Candidate Key Candidate key is a key of a table which can be selected as a primary key of the table. A table can have multiple candidate keys, out of which one can be selected as a primary key. Example : Employee_Id, License_Number and Passport_Number are candidate keys Primary Key Primary key is a candidate key of the table selected to...

Comments
Post a Comment