Presentation is loading. Please wait.

Presentation is loading. Please wait.

DBAdmin D D D D D a a a a a t t t t t a a a a a b b b b b a a a a a s s s s s e e e e eAdministration / Embedded SQL by: Glen Orsburn Chapter 6.

Similar presentations


Presentation on theme: "DBAdmin D D D D D a a a a a t t t t t a a a a a b b b b b a a a a a s s s s s e e e e eAdministration / Embedded SQL by: Glen Orsburn Chapter 6."— Presentation transcript:

1 DBAdmin D D D D D a a a a a t t t t t a a a a a b b b b b a a a a a s s s s s e e e e eAdministration / Embedded SQL by: Glen Orsburn Chapter 6

2 Database Administration Views Security using Grant and Revoke Creating an Index Advantages /Disadvantages SQL Catalog Integrity

3 Views Create view Database as Select packid, packname, packcost from package where packtype = ‘Database’ When we do the following... Select * from Database where packcost > 400 The SQL engine translates the select of the view to the original select. Select packid, packname, packcost from package where packtype = ‘Database’ and packcost > 400

4 Creating a view and change column names. Create view Database (pkid, name, cost) as Select packid, packname, packcost from package where packtype = ‘Database’ Prompt F4 --

5 Specify CREATE VIEW Statement Type choices, press Enter. View......... softpack Name Library...... goolib Name, F4 for list Field names for view 1 1=Use result file names 2=Specify names WITH CHECK OPTION.. 1 1=NONE 2=CASCADED 3=LOCAL CHECK OPTION is a validity check that can be placed in SQL views. The possible choices are: CASCADED check specifies the constraint LOCAL conform to the definition of that view

6 Views - Advantages Views provide data independence. If the underlying table structure is to change, a view may still be created that would emulate the original structure. The same data can be viewed by different users in different ways. A view should only contain the information a given user or group needs to see.

7 Views - Disadvantages Views can be difficult to impossible to update without violating referential integrity. Many systems do not allow updates of a view that incorporates a join.

8 Removing a View Syntax Drop view Database http://publib.boulder.ibm.com/pubs/html/as400/online/v4r3eng.htm

9 Security Grant - This command allows a user to access a particular object. Revoke - This command disallows a user to access a particular object. Syntax... Grant operation on object to user –Operation can be select, insert, update, delete, index, alter or all. –Object is a table, view or stored procedure –User is the UserID

10 Indexes Speeds access to records by keeping track of row numbers for a selected attribute (or set of attributes). Advantage - Increases speed to access specific data points. Disadvantage - Slows updates, inserts and deletes due to overhead of updating index table and data table.

11 Index Syntax Create [unique] index ind_packid on package (packid) An index may be made from more than one field... Create index ind_empname on employee(firstname, lastname) To drop an index... Drop Index indexname Optional Index Name Table field to index

12 System Catalog A set of related tables that define all objects in the database. –SYSTABLES - Information about all of the tables in the database (name, creator, creation date…) –SYSCOLUMNS -Information about the columns within the tables (datatypes, length, null allowed…) –SYSINDEXES - Information about the indexes on the tables (attribute being indexed, unique

13 select * from syscolumns SYSCHKCST *FILE LF 24576 SQL catalog view SYSCOLUMNS *FILE LF 49152 SQL catalog view SYSCST *FILE LF 49152 SQL catalog view SYSCSTCOL *FILE LF 40960 SQL catalog view SYSCSTDEP *FILE LF 40960 SQL catalog view SYSINDEXES *FILE LF 65536 SQL catalog view SYSKEYCST *FILE LF 69632 SQL catalog view SYSKEYS *FILE LF 49152 SQL catalog view SYSPACKAGE *FILE LF 69632 SQL catalog view SYSREFCST *FILE LF 40960 SQL catalog view SYSTABLES *FILE LF 40960 SQL catalog view SYSVIEWDEP *FILE LF 65536 SQL catalog view SYSVIEWS *FILE LF 36864 SQL catalog view System Catalog - Views

14 Database Integrity IEF - Integrity Enhancement Feature. An ANSI standard for supporting integrity. The following are added to the ‘create table ‘ SQL. –Check (location IN (‘Accounting’, ‘Sales’, ‘Home’)) –Primary Key (tagnum) –Foreign Key (compid) references computer

15 Integrity Example CREATE TABLE pc (tagnumchar(5), compidchar(4), empnumdecimal(3,0), locationchar(12), CHECK (location IN (‘Accounting’, ‘Sales’, ‘Home’)) PRIMARY KEY (tagnum) FOREIGN KEY (compid) REFERENCES computer

16 HLL - Similar statement we have been using in ISQL (Interactive SQL)


Download ppt "DBAdmin D D D D D a a a a a t t t t t a a a a a b b b b b a a a a a s s s s s e e e e eAdministration / Embedded SQL by: Glen Orsburn Chapter 6."

Similar presentations


Ads by Google