Browsed by
Tag: Database Management System Notes

Can you explain the SELECT INTO Statement

Can you explain the SELECT INTO Statement

SELECT INTO statement is used mostly to create backups. The below SQL backsup the Employee table in to the EmployeeBackUp table. One point to be noted is that the structure of pcdsEmployeeBackup and pcdsEmployee table should be same. SELECT * INTO pcdsEmployeeBackup FROM pcdsEmployee. Certainly! The SELECT INTO statement in a database management system (DBMS) is used to create a new table based on the result set returned by a SELECT query. Here’s how it works: SELECT Query: First, you…

Read More Read More

Which will return: Peter and Amanda

Which will return: Peter and Amanda

If you want to find out the number of descendants for a node, all you need is the left_val and right_val of the node for which you want to find the  descendants  count. The formula is No. of descendants = (right_val – left_val -1) /2 So,  for 6 -11 Amanda, (11 – 6 – 1) /2 =  2 descendants for 1-12  Peter, (12 – 1 -1 ) / 2 = 5 descendants. for 3-4   Mary, (4 -3 – 1) / 2 =  0,…

Read More Read More

How do we select distinct values from a table

How do we select distinct values from a table

DISTINCT keyword is used to return only distinct values. Below is syntax:- Column age and Table pcdsEmp SELECT DISTINCT age FROM pcdsEmp To select distinct values from a table in a relational database management system (DBMS), you would typically use the SELECT DISTINCT statement. Here’s the general syntax: sql SELECT DISTINCT column1, column2, … FROM table_name; This query will return only unique values from the specified columns in the table. If you want distinct values from all columns, you can…

Read More Read More

What is a View

What is a View

View is a virtual table which is created on the basis of the result set returned by the select statement. CREATE VIEW [MyView] AS SELECT * from pcdsEmployee where LastName = ‘singh’ In order to query the view SELECT * FROM [MyView] A view in a database management system (DBMS) is a virtual table that is based on the result of a SELECT query. It presents data from one or more tables in the database in a structured format, similar…

Read More Read More

What is Like operator for and what are wild cards

What is Like operator for and what are wild cards

LIKE operator is used to match patterns. A “%” sign is used to define the pattern. Below SQL statement will return all words with letter “S” SELECT * FROM pcdsEmployee WHERE EmpName LIKE ‘S%’ Below SQL statement will return all words which end with letter “S” SELECT * FROM pcdsEmployee WHERE EmpName LIKE ‘%S’ Below SQL statement will return all words having letter “S” in between SELECT * FROM pcdsEmployee WHERE EmpName LIKE ‘%S%’   “_” operator (we can read…

Read More Read More

What is SQLinjection

What is SQLinjection

It is a Form of attack on a database-driven Web site in which the attacker executes unauthorized SQL commands by taking advantage of insecure code on a system connected to the Internet, bypassing the firewall. SQL injection attacks are used to steal information from a database from which the data would normally not be available and/or to gain access to an organization’s host computers through the computer that is hosting the database. SQL injection attacks typically are easy to avoid…

Read More Read More

Can you explain Insert, Update and Delete query

Can you explain Insert, Update and Delete query

Insert statement is used to insert new rows in to table. Update to update existing data in the table. Delete statement to delete a record from the table. Below code snippet for Insert, Update and Delete :- INSERT INTO pcdsEmployee SET name=’rohit’,age=’24’; UPDATE pcdsEmployee SET age=’25’ where name=’rohit’; DELETE FROM pcdsEmployee WHERE name = ‘sonia’; Sure, here’s a brief explanation of Insert, Update, and Delete queries in a database management system (DBMS): Insert Query: An Insert query is used to…

Read More Read More

What is Data Warehousing

What is Data Warehousing

Data Warehousing is a process in which the data is stored and accessed from central location and is meant to support some strategic decisions. Data Warehousing is not a requirement for Data mining. But just makes your Data mining process more efficient. Data warehouse is a collection of integrated, subject-oriented databases designed to support the decision-support functions (DSF), where each unit of data is relevant to some moment in time.

What is the SQL “in” clause

What is the SQL “in” clause

SQL IN operator is used to see if the value exists in a group of values. For instance the below SQL checks if the Name is either ‘rohit’ or ‘Anuradha’ SELECT * FROM pcdsEmployee WHERE name IN (‘Rohit’,’Anuradha’) Also you can specify a not clause with the same. SELECT * FROM pcdsEmployee WHERE age NOT IN (17,16).

What are Data Marts

What are Data Marts

Data Marts are smaller section of Data Warehouses. They help data warehouses collect data. For example your company has lot of branches which are spanned across the globe. Head-office of the company decides to collect data from all these branches for anticipating market. So to achieve this IT department can setup data mart in all branch offices and a central data warehouse where all data will finally reside.