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
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...
DML OPERATIONS: Data Manipulation Language is a one of the Subset of SQL. These SQL commands are used to store, modify, and delete data from database tables. In this category we have INSERT, UPDATE, and DELETE commands. Different DML statements are • Select • Insert • Update • Delete Select: The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. The SELECT command is the most commonly used command in SQL. It allows database users to retrieve the specific information they desire from an operational database. Syntax: SELECT column_name(s) FROM table_name and SELECT * FROM table_name Example: consider the table student_details. To select the first name of all the students the query would be SELECT first_name FROM student_details; If we want to select all the columns from the table, we use the following SELECT statement: SELECT * FROM student_details; Insert: The ...

Comments
Post a Comment