KEMBAR78
Module-4.1 DBMS | PDF | Databases | Sql
0% found this document useful (0 votes)
70 views31 pages

Module-4.1 DBMS

Uploaded by

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

Module-4.1 DBMS

Uploaded by

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

SCHEME - 2022

Module - 4
BCS403-Database Management System

Advances Quieries

More Complex SQL Retrieval Queries More Complex SQL Retrieval


Queries
described some basic types of retrieval queries in SQL.

Because of the generality and expressive power of the language, there are many additional
features that allow users to specify more complex retrievals from the database.

Comparisons Involving NULL and Three-Valued Logic


 SQL has various rules for dealing with NULL values.
 Recall from Section 5.1.2 that NULL is used to represent a missing value, but that it
usually has one of three different interpretations—value unknown (value exists but is not
known, or it is not known whether the value exists).
 value not available (value exists but is purposely withheld), or value not applicable
(the attribute does not apply to this tuple or is undefined for this tuple).
 Consider the following examples to illustrate each of the meanings of NULL.

THARANI R Page 1
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 Each expression result would have a value of TRUE, FALSE, or UNKNOWN.


 Tuple combinations that evaluate to FALSE or UNKNOWN are not selected.
 SQL allows queries that check whether an attribute value is NULL. Rather than using
= or <> to compare an attribute value to NULL, SQL uses the comparison operators IS
or IS NOT.
 Query 18 illustrates NULL comparison by retrieving any employees who do not have
a supervisor.

Nested Queries, Tuples, and Set/Multiset Comparisons


 Some queries require that existing values in the database be fetched and then used in
a comparison condition.
 Such queries can be conveniently formulated by using nested queries, which are
complete select-from-where blocks within another SQL query.
 That other query is called the outer query.
 These nested queries can also appear in the WHERE clause or the FROM clause or
the SELECT clause or other SQL clauses as needed.
 Query 4 is formulated in Q4 without a nested query, but it can be rephrased to use
nested queries as shown in Q4A.

THARANI R Page 2
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 In the outer query, we use the OR logical connective to retrieve a PROJECT tuple if
the PNUMBER value of that tuple is in the result of either nested query.

 SQL allows the use of tuples of values in comparisons by placing them


within parentheses. To illustrate this, consider the following query:

 This query will select the Essns of all employees who work the same (project, hours)
combination on some project that employee ‘John Smith’ (whose Ssn =
‘123456789’) works on.
 The keyword ALL can also be combined with each of these operators.
 An example is the following query, which returns the names of employees whose salary
is greater than the salary of all the employees in department 5:

 In general, we can have several levels of nested queries.

THARANI R Page 3
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 To illustrate the potential ambiguity of attribute names in nested queries, consider


Query 16.

Correlated Nested Queries


 Whenever a condition in the WHERE clause of a nested query references some
attribute of a relation declared in the outer query, the two queries are said to be
correlated.
 We can understand a correlated query better by considering that the nested query
is evaluated once for each tuple (or combination of tuples) in the outer query.
 For example, we can think of Q16 as follows: For each EMPLOYEE tuple, evaluate
the nested query, which retrieves the Essn values for all DEPENDENT tuples with the
same sex and name as that EMPLOYEE tuple;
 if the Ssn value of the EMPLOYEE tuple is in the result of the nested query, then
select that EMPLOYEE tuple.

The EXISTS and UNIQUE Functions in SQL


 EXISTS and UNIQUE are Boolean functions that return TRUE or FALSE; hence,
they can be used in a WHERE clause condition.
 The EXISTS function in SQL is used to check whether the result of a nested query
is empty (contains no tuples) or not.
 The result of EXISTS is a Boolean value TRUE if the nested query result contains at
least one tuple, or FALSE if the nested query result contains no tuples.

THARANI R Page 4
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System
 We illustrate the use of EXISTS—and NOT EXISTS—with some examples.

THARANI R Page 5
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 First, we formulate Query 16 in an alternative form that uses EXISTS as in Q16B:

 EXISTS and NOT EXISTS are typically used in conjunction with a


correlated nested query.In Q16B, the nested query references the Ssn,
Fname, and Sex attributes of the EMPLOYEE relation from the outer
query.

THARANI R Page 6
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 It corresponds to the way we will write this query in tuple relation calculus.
 There is another SQL function, UNIQUE(Q), which returns TRUE if there are
no duplicate tuples in the result of query Q; otherwise, it returns FALSE.
 This can be used to test whether the result of a nested query is a set (no duplicates) or
a multiset (duplicates exist).

Explicit Sets and Renaming in SQL


 We have seen several queries with a nested query in the WHERE clause.
 It is also possible to use an explicit set of values in the WHERE clause, rather than
a nested query.
 Such a set is enclosed in parentheses in SQL.

THARANI R Page 7
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 In SQL, it is possible to rename any attribute that appears in the result of a query
by adding the qualifier AS followed by the desired new name.
 Hence, the AS construct can be used to alias both attribute and relation names in
general, and it can be used in appropriate parts of a query.
 For example, Q8A shows how query Q8 from Section 4.3.2 can be slightly changed
to retrieve the last name of each employee and his or her supervisor while renaming
the resulting attribute names as Employee_name and Supervisor_name.
 The new names will appear as column headers for the query result.

Joined Tables in SQL and Outer Joins


 The concept of a joined table (or joined relation) was incorporated into SQL to
permit users to specify a table resulting from a join operation in the FROM clause
of a query.
 This construct may be easier to comprehend than mixing together all the select and
join conditions in the WHERE clause.
 For example, consider query Q1, which retrieves the name and address of every
employee who works for the ‘Research’ department.
 It may be easier to specify the join of the EMPLOYEE and DEPARTMENT relations
in the WHERE clause, and then to select the desired tuples and attributes.
 This can be written in SQL as in Q1A:

 If the user requires that all employees be included, a different type of join called
OUTER JOIN must be used explicitly.
 There are several variations of OUTER JOIN, as we shall see.

THARANI R Page 8
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 In the SQL standard, this is handled by explicitly specifying the keyword OUTER
JOIN in a joined table, as illustrated in Q8B:

 In SQL, the options available for specifying joined tables include INNER JOIN
(only pairs of tuples that match the join condition are retrieved, same as JOIN).
 LEFT OUTER JOIN (every tuple in the left table must appear in the result; if it does not
have a matching tuple, it is padded with NULL values for the attributes of the right
table).
 RIGHT OUTER JOIN (every tuple in the right table must appear in the result; if it
does not have a matching tuple, it is padded with NULL values for the attributes of the
left table), and FULL OUTER JOIN.

Aggregate Functions in SQL


 Aggregate functions are used to summarize information from multiple tuples into
a single-tuple summary.
 Grouping is used to create subgroups of tuples before summarization.
 Grouping and aggregation are required in many database applications, and we
will introduce their use in SQL through examples.
 A number of built-in aggregate functions exist: COUNT, SUM, MAX, MIN, and AVG.
 The COUNT function returns the number of tuples or values as specified in a query.
 The functions SUM, MAX, MIN, and AVG can be applied to a set or multiset of
numeric values and return, respectively, the sum, maximum value, minimum value, and

THARANI R Page 9
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System
average (mean) of those values.

THARANI R Page 10
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 These functions can be used in the SELECT clause or in a HAVING clause (which
we introduce later).
 The functions MAX and MIN can also be used with attributes that have
nonnumeric domains if the domain values have a total ordering among one another.
 We illustrate the use of these functions with several queries.

THARANI R Page 11
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Grouping: The GROUP BY and HAVING Clauses


 In many cases we want to apply the aggregate functions to subgroups of tuples in
a relation, where the subgroups are based on some attribute values.
 In these cases we need to partition the relation into nonoverlapping subsets (or groups)
of tuples.
 Each group (partition) will consist of the tuples that have the same value of some
attribute(s), called the grouping attribute(s).
 We can then apply the function to each such group independently to produce
summary information about each group.
 SQL has a GROUP BY clause for this purpose.
 The GROUP BY clause specifies the grouping attributes, which should also appear in
the SELECT clause, so that the value resulting from applying each aggregate function to
a group of tuples appears along with the value of the grouping attribute(s).

THARANI R Page 12
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 Sometimes we want to retrieve the values of these functions only for groups
that satisfy certain conditions.
 For example, suppose that we want to modify Query 25 so that only projects with
more than two employees appear in the result.
 SQL provides a HAVING clause, which can appear in conjunction with a GROUP
BY clause, for this purpose.

THARANI R Page 13
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

THARANI R Page 14
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 For example, suppose that we want to count the total number of employees whose
salaries exceed Rs.40,000 in each department, but only for departments where more than
five employees work.
 Here, the condition (SALARY > 40000) applies only to the COUNT function in
the SELECT clause.
 Suppose that we write the following incorrect query:

 This is incorrect because it will select only departments that have more than
five employees who each earn more than $.40,000.
 The rule is that the WHERE clause is executed first, to select individual tuples or
joined tuples; the HAVING clause is applied later, to select individual groups of tuples.
 In the incorrect query, the tuples are already restricted to employees who earn more than
$.40,000 before the function in the HAVING clause is applied.
 One way to write this query correctly is to use a nested query, as shown in Query 28.

THARANI R Page 15
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Other SQL Constructs: WITH and CASE


 In this section, we illustrate two additional SQL constructs.
 The WITH clause allows a user to define a table that will only be used in a
particular query; it is somewhat similar to creating a view (see Section 7.3) that will
be used only in one query and then dropped.
 This construct was introduced as a convenience in SQL:99 and may not be available
in all SQL based DBMSs. Queries using WITH can generally be written using other
SQL constructs.
 For example, we can rewrite Q28 as Q28′:

THARANI R Page 16
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Recursive Queries in SQL


 This syntax was added in SQL:99 to allow users the capability to specify a
recursive query in a declarative manner.
 An example of a recursive relationship between tuples of the same type is the
relationship between an employee and a supervisor.
 This relationship is described by the foreign key Super_ssn of the EMPLOYEE
relation in Figures 5.5 and 5.6, and it relates each employee tuple (in the role of
supervisee) to another employee tuple (in the role of supervisor).
 An example of a recursive operation is to retrieve all supervisees of a supervisory
employee e at all levels—that is, all employees e′ directly supervised by e, all
employees e′ directly supervised by each employee e′, all employees e″′ directly
supervised by each employee e″, and so on.
 In SQL:99, this query can be written as follows:

 The view is initially empty. It is first loaded with the first level (supervisor,
supervisee) Ssn combinations via the first part (SELECT SupervisorSss, Ssn
FROMEMPLOYEE), which is called the base query.
 At this point, the result of the recursive query is in the view SUP_EMP.

THARANI R Page 17
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Discussion and Summary of SQL Queries


 A retrieval query in SQL can consist of up to six clauses, but only the first two
— SELECT and FROM—are mandatory.
 The query can span several lines, and is ended by a semicolon.
 Query terms are separated by spaces, and parentheses can be used to group
relevant parts of a query in the standard way.
 The clauses are specified in the following order, with the clauses between
square brackets [ … ] being optional:

 The SELECT clause lists the attributes or functions to be retrieved.


 The FROM clause specifies all relations (tables) needed in the query, including
joined relations, but not those in nested queries.
 The WHERE clause specifies the conditions for selecting the tuples from these
relations, including join conditions if needed.
 GROUP BY specifies grouping attributes, whereas HAVING specifies a condition on
the groups being selected rather than on the individual tuples.
 The built-in aggregate functions COUNT, SUM, MIN, MAX, and AVG are used in
conjunction with grouping, but they can also be applied to all the selected tuples in
a query without a GROUP BY clause.
 Finally, ORDER BY specifies an order for displaying the result of a query.
 GROUP BY and HAVING. Conceptually, ORDER BY is applied at the end to sort
the query result.
 The disadvantage of having numerous ways of specifying the same query is that this may
confuse the user, who may not know which technique to use to specify particular types
of queries.

THARANI R Page 18
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Specifying Constraints as Assertions and Actions as Triggers


 In this section, we introduce two additional features of SQL: the CREATE
ASSERTION statement and the CREATE TRIGGER statement.
 CREATE ASSERTION, which can be used to specify additional types of constraints
that are outside the scope of the built-in relational model constraints (primary and unique
keys, entity integrity, and referential integrity) that we presented.
 These built-in constraints can be specified within the CREATE TABLE statement
of SQL.
 introduce CREATE TRIGGER, which can be used to specify automatic actions that
the database system will perform when certain events and conditions occur.
 This type of functionality is generally referred to as active databases.
 We only introduce the basics of triggers in this chapter, and present a more
complete discussion of active databases.

Specifying General Constraints as Assertions in SQL


 In SQL, users can specify general constraints—those that do not fall into any of
the categories described in Sections 6.1 and 6.2— via declarative assertions, using
the CREATE ASSERTION statement.
 Each assertion is given a constraint name and is specified via a condition similar to
the WHERE clause of an SQL query.
 For example, to specify the constraint that the salary of an employee must not be greater
than the salary of the manager of the department that the employee works for in SQL,
we can write the following assertion:

THARANI R Page 19
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

Introduction to Triggers in SQL


 In many cases it is convenient to specify the type of action to be taken when
certain events occur and when certain conditions are satisfied.
 For example, it may be useful to specify a condition that, if violated, causes some user
to be informed of the violation.
 A manager may want to be informed if an employee’s travel expenses exceed a
certain limit by receiving a message whenever this occurs.
 The action that the DBMS must take in this case is to send an appropriate message to
that user. The condition is thus used to monitor the database.
 Other actions may be specified, such as executing a specific stored procedure or
triggering other updates. The CREATE TRIGGER statement is used to implement
such actions in SQL.
 We discuss triggers in detail in Section 26.1 when we describe active databases. Here
we just give a simple example of how triggers may be used.
 Suppose we want to check whenever an employee’s salary is greater than the salary of
his or her direct supervisor in the COMPANY database.
 Triggers can be used in various applications, such as maintaining database
consistency, monitoring database updates, and updating derived data automatically.

The event(s):
 These are usually database update operations that are explicitly applied to the database.
 In this example the events are: inserting a new employee record, changing an
employee’s salary, or changing an employee’s supervisor.
 The person who writes the trigger must make sure that all possible events are
accounted for. In some cases, it may be necessary to write
 more than one trigger to cover all possible cases.

THARANI R Page 20
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 These events are specified after the keyword BEFORE in our example, which means
that the trigger
 should be executed before the triggering operation is executed.
 An alternative is to use the keyword AFTER, which specifies that the trigger should be
 executed after the operation specified in the event is completed.

The condition that determines whether the rule action should be


executed:
 Once the triggering event has occurred, an optional condition may be evaluated. If
no condition is specified, the action will be executed once the event occurs.
 If a condition is specified, it is first evaluated, and only if it evaluates to true will the
rule action be executed.
 The condition is specified in the WHEN clause of the trigger.
The action to be taken:
 The action is usually a sequence of SQL statements, but it could also be a
database transaction or an external program that will be automatically executed.
 In this example, the action is to execute the stored procedure INFORM_SUPERVISOR.
Views (Virtual Tables) in SQL
In this section we introduce the concept of a view in SQL.

We show how views are specified, and then we discuss the problem of updating views and
how views can be implemented by the DBMS.

Concept of a View in SQL


 A view in SQL terminology is a single table that is derived from other tables.6
These other tables can be base tables or previously defined views.
 A view does not necessarily exist in physical form; it is considered to be a virtual table,
in contrast to base tables, whose tuples are always physically stored in the database.
 This limits the possible update operations that can be applied to views, but it does
not provide any limitations on querying a view.
 We can think of a view as a way of specifying a table that we need to
reference frequently, even though it may not exist physically.
 For example, referring to the COMPANY database in Figure 5.5, we may frequently
issue queries that retrieve the employee name and the project names that the employee
works on. Rather than having to specify the join of the three tables EMPLOYEE,
WORKS_ON, and PROJECT every time we issue this query, we can define a view that is
specified as the result of these joins.

THARANI R Page 21
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 Then we can issue queries on the view, which are specified as single table
retrievals rather than as retrievals involving two joins on three tables.
 We call the EMPLOYEE, WORKS_ON, and PROJECT tables the defining tables of
the view.

Specification of Views in SQL


 In SQL, the command to specify a view is CREATE VIEW.he view is given a
(virtual) table name (or view name), a list of attribute names, and a query to
specify the contents of the view.
 If none of the view attributes results from applying functions or arithmetic
operations, we do not have to specify new attribute names for the view, since they
would be the same as the names of the attributes of the defining tables in the default
case.
 The views in V1 and V2 create virtual tables whose schemas are illustrated in
Figure 7.2 when applied to the database schema of Figure 5.5.

 In V1, we did not specify any new attribute names for the view WORKS_ON1 (although
we could have); in this case, WORKS_ON1 inherits the names of the view attributes
from the defining tables EMPLOYEE, PROJECT, and WORKS_ON.

THARANI R Page 22
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 View V2 explicitly specifies new attribute names for the view DEPT_INFO, using a one-
to-one correspondence between the attributes specified in the CREATE VIEW clause
and those specified in the SELECT clause of the query that defines the view.
 We can now specify SQL queries on a view—or virtual table—in the same way
we specify queries involving base tables.
 For example, to retrieve the last name and first name of all employees who work on
the ‘ProductX’ project, we can utilize the WORKS_ON1 view and specify the query as
in QV1:

 Views are also used as a security and authorization mechanism.


 A view is supposed to be always up-to-date; if we modify the tuples in the base tables
on which the view is defined, the view must automatically reflect these changes.

View Implementation, View Update, and Inline Views


 The problem of how a DBMS can efficiently implement a view for efficient querying
is complex. Two main approaches have been suggested.
 One strategy, called query modification, involves modifying or transforming the
view query (submitted by the user) into a query on the underlying base tables.
 For example, the query QV1 would be automatically modified to the following query
by the DBMS:

 The disadvantage of this approach is that it is inefficient for views defined via complex
queries that are time-consuming to execute, especially if multiple view queries are
going to be applied to the same view within a short period of time.
 This view update is shown in UV1:

THARANI R Page 23
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 This query can be mapped into several updates on the base relations to give the
desired update effect on the view.
 In addition, some of these updates will create additional side effects that affect the
result of other queries.
 For example, here are two possible updates, (a) and (b), on the base
relations corresponding to the view update operation in UV1:

 Update (a) relates ‘John Smith’ to the ‘ProductY’ PROJECT tuple instead of
the ‘ProductX’ PROJECT tuple and is the most likely desired update.

In summary, we can make the following observations:

A view with a single defining table is updatable if the view attributes contain the
primary key of the base relation, as well as all attributes with the NOT NULL
constraint that do not have default values specified.
Views defined on multiple tables using joins are generally not updatable.
Views defined using grouping and aggregate functions are not updatable.

THARANI R Page 24
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 In SQL, the clause WITH CHECK OPTION should be added at the end of the view
definition if a view is to be updated by INSERT, DELETE, or UPDATE
statements.
 This allows the system to reject operations that violate the SQL rules for view updates.
 The full set of SQL rules for when a view may be modified by the user are more
complex than the rules stated earlier.
 It is also possible to define a view table in the FROM clause of an SQL query.
 This is known as an in-line view. In this case, the view is defined within the query itself.
Views as Authorization Mechanisms
 We describe SQL query authorization statements (GRANT and REVOKE) when
we present database security and authorization mechanisms.
 Here, we will just give a couple of simple examples to illustrate how views can be
 used to hide certain attributes or tuples from unauthorized users.
 Suppose a certain user is only allowed to see employee information for employees who
work for department 5; then we can create the following view DEPT5EMP and grant
the user the privilege to query the view but not the base table EMPLOYEE itself.
 This user
 will only be able to retrieve employee information for employee tuples whose
 Dno = 5, and will not be able to see other employee tuples when the view is queried.

Schema Change Statements in SQL


 In this section, we give an overview of the schema evolution commands available
in SQL, which can be used to alter a schema by adding or dropping tables,
attributes, constraints, and other schema elements.
THARANI R Page 25
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 This can be done while the database is operational and does not require
recompilation of the database schema.
 Certain checks must be done by the DBMS to ensure that the changes do not
affect the rest of the database and make it inconsistent.

The DROP Command


 The DROP command can be used to drop named schema elements, such as
tables, domains, types, or constraints.
 One can also drop a whole schema if it is no longer needed by using the DROP
SCHEMA command.
 There are two drop behavior options: CASCADE and RESTRICT.
 For example, to remove the COMPANY database schema and all its tables, domains,
and other elements, the CASCADE option is used as follows:

DROP SCHEMA COMPANY CASCADE;

 If the RESTRICT option is chosen in place of CASCADE, the schema is dropped only
if it has no elements in it;
 otherwise, the DROP command will not be executed. To use the RESTRICT option, the
user must first individually drop each element in the schema, then drop the schema
itself.
 If a base relation within a schema is no longer needed, the relation and its definition
can be deleted by using the DROP TABLE command.
 For example, if we no longer wish to keep track of dependents of employees in the
COMPANY database of Figure 6.1, we can get rid of the DEPENDENT relation
by issuing the following command:

DROP TABLE DEPENDENT CASCADE;

 The DROP command can also be used to drop other types of named schema
elements, such as constraints or domains.

The ALTER Command


 The definition of a base table or of other named schema elements can be changed
by using the ALTER command.
 For base tables, the possible alter table actions include adding or dropping a
column (attribute), changing a column definition, and adding or dropping table
constraints.

THARANI R Page 26
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

 For example, to add an attribute for keeping track of jobs of employees to the
EMPLOYEE base relation in the COMPANY schema (see Figure 6.1), we can use
the command

ALTER TABLE COMPANY.EMPLOYEE ADD COLUMN Job VARCHAR(12);

 This is specified by using the ADD


CONSTRAINT keyword in the ALTER
TABLE statement followed by the new
constraint, which can be named or unnamed and
can be of any of the table constraint types
discussed.
 The preceding subsections gave an overview of
the schema evolution commands of SQL. It is
also possible to create new tables and views
within a database schema using the appropriate

THARANI R Page 27
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

THARANI R Page 28
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

THARANI R Page 29
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

THARANI R Page 30
Asst. Professor, Dept. of AI & ML
SCHEME - 2022

Module - 4
BCS403-Database Management System

THARANI R Page 31
Asst. Professor, Dept. of AI & ML

You might also like