Professional Documents
Culture Documents
Jeena C D
Jeena C D
-------------------------------------------------------------------------------------------------------------------Built-in Functions
in Python: Python provides a rich set of built-in functions that simplify common tasks. These functions
cover a wide range of operations, from mathematical calculations to string manipulation. Some
commonly used built-in functions include: abs(): Returns the absolute value of a number.
all(): Checks if all elements in an iterable are True.
any(): Checks if any element in an iterable is True. enumerate():
Generates an index-value pair for each element in an iterable.
--------------------------------------------------------------------------------------------------------------
Built-in Functions in Python: Python provides a rich set of built-in functions that simplify common tasks.
These functions cover a wide range of operations, from mathematical calculations to string
manipulation. Some commonly used built-in functions include: abs(): Returns the absolute
value of a number. all(): Checks if all elements in an
iterable are True. any(): Checks if any element in an
iterable is True. enumerate(): Generates an index-value pair
for each element in an iterable.
1Views in Database Management Systems (DBMS): Views are virtual tables created by querying existing
tables. They allow you to present a subset of data or combine data from multiple tables. Views enhance
security by controlling access to specific columns or rows. 2 Security Amongst Users: In a database
system, user security is crucial. You can control access rights, permissions, and privileges to ensure data
confidentiality and integrity. Common security mechanisms include authentication, authorization, and
encryption. 3 Sequences: Sequences are ordered collections of elements. In Python, you have
various sequence types like lists, tuples, and strings. They allow indexing, slicing, and iteration. 4
Indexing: Indexing improves query performance by creating data structures (indexes) that allow efficient
data retrieval. In databases, indexes speed up search operations. 4 Object-Oriented Features: Oracle
10g supports object-oriented features, allowing you to create user-defined data types (objects) and
methods associated with them.
=--------------------------------------------------------------------------------------------------------
Features of PL/SQL: Procedural Language Elements: PL/SQL includes constructs like conditions, loops,
and exception handling. Declaration of Constants and Variables: You can declare constants,
variables, and data types. Procedures and Functions: Create reusable code blocks for specific tasks.
Triggers: Define actions to be executed automatically when certain events occur. Exception
Handling: Handle errors gracefully within PL/SQL blocks. Portability: Applications written in PL/SQL
can run on different hardware or operating systems where Oracle is operational.
Differences Between SQL and PL/SQL: SQL: Executes a single query for data manipulation (DML)
and data definition (DDL). Mainly used to manipulate data directly. Cannot contain PL/SQL code.
PL/SQL: Consists of blocks (procedures, functions, etc.). Executes as a whole block. Used to
create applications and perform complex tasks. Can contain SQL statements.
SQL
DECLAR -- Declaration statements (variables, constants, etc.)
(BEGIN ) -- Executable statements (EXCEPTION) -- Exception handling statements (END;) AI-
generated code. Review and use carefully. More info on FAQ. The DECLARE section defines variables
and other identifiers.
------------------------------------------------------------------------------------
implem,ent cursors and explicit cursors in the context of database management systems (DBMS):
Implicit Cursors: Automatically created by the Oracle database when executing SELECT statements.
No need for explicit declaration by the user. Fetch single rows at a time. Close automatically after
execution. Less efficient due to limited control. Explicit Cursors: User-defined by
explicitly providing a name. Capable of fetching multiple rows. Must be closed explicitly.
Provides full control to the programmer. More efficient than implicit cursors.
---------------------------------------------------------------------------
-----------------------------------------------------------------
database triggers. A trigger is procedural code that automatically executes in response to specific events
on a particular table or view within a database1. Here are the key points about triggers: Types of
Triggers: 1 AFTER INSERT: Activated after data is inserted into the table. 2 AFTER UPDATE: Activated
after data in the table is modified. 3 AFTER DELETE: Activated after data is deleted or removed from the
table. 4 BEFORE INSERT: Activated before data is inserted into the table. 5 BEFORE UPDATE: Activated
before data in the table is modified 6 BEFORE DELETE: Activated before data is deleted or removed
from the table. Examples: To ensure no employee under 25 is inserted, you can create a trigger like
this:
SQL CREATE TRIGGER CheckAge BEFORE INSERT ON employee FOR EACH ROW
BEGIN IF NEW.age < 25 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'ERROR:
AGE MUST BE AT LEAST 25 YEARS!'; END IF; END; AI-generated code. Review and
use carefully. More info on FAQ. To create a backup of records before deletion:
SQL CREATE TABLE employee_backup (employee_no INT, employee_name VARCHAR(40), job
VARCHAR(40), hiredate DATE, salary INT, PRIMARY KEY(employee_no)); CREATE TRIGGER Backup
BEFORE DELETE ON employe FOR EACH ROW BEGIN INSERT INTO employee_backup VALUES
(OLD.employee_no, OLD.name, OLD.job, OLD.hiredate, OLD.salary); END; AI-generated code.
Review and use carefully. More info on FAQ. To count new tuples inserted SQL
DECLARE count INT; SET count = 0; CREATE TRIGGER CountTuple AFTER INSERT ON
employee FOR EACH ROW BEGIn SET count = count + 1; END; AI-generated
code. Review and use carefully. More info on FAQ. Remember, triggers help maintain data integrity
and automate actions based on database events