Professional Documents
Culture Documents
DBMS Practical - Removed
DBMS Practical - Removed
Ans:
DDL-Commands:
1. Create
2. Alter
3. drop
1. Create
2. Alter Command
3. Drop table
2. Select
3. Delete
4. Insert
1. Update Command
2.Select Command
3. Delete Command
4. Insert Command
3) Implement SELECT command with different clauses.
Ans:
The select statement is used to get the required data from the database according to
<Student>
Query −
Select Student_Name
From Student
The example of select statement given above is quite simple and not that useful in
practice. So, there are many other clauses associated with select statement that make
Where
The where clause is used to filter out data i.e. it returns information that satisfies a
Select Student_Name
From Student
This is mostly used with aggregate functions to group the result set according to the
From Student
Group by Student_MajorSubject
Having
This is used along with Group By clause because Where clause could not be used by
From Student
Group by Student_MajorSubject
The order by keyword is used to sort the results in ascending or descending order. By
Select Student_Name
From Student
Where Student_Marks>50
Order by Student_Marks
Integrity Constraints
• Integrity constraints are a set of rules. It is used to maintain the quality of information.
• Integrity constraints ensure that the data insertion, updating, and other processes have
• Thus, integrity constraint is used to guard against accidental damage to the database.
1. Domain constraints
• Domain constraints can be defined as the definition of a valid set of values for an
• attribute.
• The data type of domain includes string, character, integer, time, date, currency, etc.
• The entity integrity constraint states that primary key value can't be null.
• This is because the primary key value is used to identify individual rows in relation and if the primary
key has a null value, then we can't identify those rows.
• A table can contain a null value other than the primary key field.
• In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary
• Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be
• available in Table 2.
4. Key constraints
• Keys are the entity set that is used to identify an entity within its entity set uniquely.
• An entity set can have multiple keys, but out of which one key will be the primary key.
• A primary key can contain a unique and null value in the relational table.
5)Implement SINGLE ROW functions (Character, Numeric,
sum).
Ans:
. COUNT FUNCTION
o COUNT function is used to Count the number of rows in a database table. It can work
o COUNT function uses the COUNT (*) that returns the count of all the rows in a
Syntax
1. COUNT (*)
2. or
3. COUNT([ALL|DISTINCT] expression)
Sample table:
PRODUCT_MAST
Item1 Com1 2 10 20
Item2 Com2 3 25 75
Item3 Com1 2 30 60
following records.
1 John 20 US 2000.00
4 Alina 29 UK 1625.00
The subquery of SQL can be used in conjunction with the Delete statement just like
Syntax
3. (SELECT COLUMN_NAME
4. FROM TABLE_NAME
5. WHERE condition);
Example
EMPLOYEE table. The given example deletes the records from the EMPLOYEE table