Database Reference
In-Depth Information
constraint Inventory_ck built on it. Simply running the above ALTER TABLE SQL statement
will cause an error.
You can also modify the length of a column. As the length of a column is reduced, the data
in that column will be truncated to it in that column. his is also true for changing data types.
he DROP keyword can be used to drop a table. he following SQL statement drops the table
IN V ENTORY:
DROP TABLE INVENTORY
If a table is referenced by a foreign key column from another table, deleting the rows in the
table or dropping the table will cause errors. Updating the rows in the referenced table can also
cause similar problems. Windows Azure SQL Database prevents you from dropping a table ref-
erenced by another table. You must drop the referencing table irst before you can drop the refer-
enced table. Windows Azure SQL Database allows you to view the dependency of the tables. As
an example, Figure 4.7 shows the dependencies on the CUSTOMER table.
4.4.3 Controlling Database Object Privileges
he database objects created by one Windows Azure SQL Database user cannot be accessed by
another Windows Azure SQL Database user without permission. he database object owner can
grant permissions to other users by using DCL commands. For example, to allow the public to
update the table PRODUCT, use the following SQL statement:
GRANT UPDATE
ON PRODUCT
TO PUBLIC
To remove a previously granted privilege on a database object, use the DCL command
REVOKE. Since it is not a good idea to grant the update permission to the public on the
PRODUCT table, it needs to be removed. To do that, run the following SQL statement:
REVOKE UPDATE
ON PRODUCT
TO PUBLIC
If you log on to a database as a database administrator, you have the privilege to grant and
revoke database object access privileges to other users.
ACTIVITY 4.2 DATABASE MANAGEMENT WITH SQL
In Chapter 3, you created the Class_Registration database. In this activity, you will cre-
ate relationships among the tables created for the Class_Registration database according to
Figure 4.11. he ALTER TABLE statement will be used to carry out the task.
1. Assume that you have logged on to the Windows Azure Management Portal. Select
the database Class_Registration and click MANAGE . hen, log on to the SQL
Database portal with your user name and password.
 
Search WWH ::




Custom Search