0% found this document useful (0 votes)
15 views

SQL Queries, Constraints and Triggers

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

SQL Queries, Constraints and Triggers

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Sql Queries,constraints And Triggers

SUBMITTED BY:
NAME:-K.SAI TEJASRI
ROLL NO:-22D21A1230
SECTION:-IT-A
Introduction to SQL Queries, Constraints, and Triggers.

• SQL queries are used to retrieve and manipulate data from relational
databases.

• Constraints are rules that enforce data integrity within a database.

• Triggers are special types of stored procedures that are automatically


executed in response to certain events.
SQL SELECT Query.

• The SELECT statement is used to query data from one or more database
tables.

• It allows filtering, sorting, and grouping of data.

• The syntax includes clauses such as WHERE, ORDER BY, and GROUP
BY.
SQL INSERT Query.

• The INSERT statement is used to add new records to a table.

• It specifies the columns and values to be inserted.

• It is important to ensure data types and constraints are satisfied when


inserting data.
SQL UPDATE Query.

• The UPDATE statement is used to modify existing records in a table.

• It specifies the columns to be updated and the new values.

• The WHERE clause is used to filter which records are updated.


SQL DELETE Query.

• The DELETE statement is used to remove records from a table.

• It can delete specific records based on conditions in the WHERE clause.

• Exercise caution when using DELETE as it permanently removes data.


Constraints in SQL.

• Constraints are used to enforce rules on data integrity.

• Common constraints include NOT NULL, UNIQUE, PRIMARY KEY,


FOREIGN KEY, and CHECK.

• Constraints help maintain data quality and consistency.


Types of Constraints.

• NOT NULL ensures a column cannot have a NULL value.

• UNIQUE ensures each value in a column is unique.

• PRIMARY KEY uniquely identifies each record in a table.


More Types of Constraints.

• FOREIGN KEY establishes a relationship between two tables.

• CHECK enforces conditions on column values.

• Constraints can be added when creating a table or altered later.


Triggers in SQL.

• Triggers are special stored procedures that are automatically executed in


response to events.

• Events can include INSERT, UPDATE, DELETE operations on a table.

• Triggers can be used to enforce business rules, audit changes, or perform


complex actions.
Creating and Managing Triggers.

• Triggers are created using the CREATE TRIGGER statement.

• They can be set to execute before or after the triggering event.

• Triggers can be disabled, enabled, or dropped as needed.


THANK YOU

You might also like