Database Reference
In-Depth Information
Figure 12.7
Error caused by missing schema name.
of the schema, the database takes the default schema dbo. Often, an unqualiied object
name will cause errors. he following example will illustrate the problem with unqual-
iied object names. As shown in Figure 12.7, the following SQL statement produces an
error message:
ALTER TABLE ACCOUNT ADD AccountName CHAR(30)
he error message indicates that the table ACCOUNT does not exist. his is because the
missing schema name in the name of the ACCOUNT table causes dbo to be the default
schema.
7. However, the table ACCOUNT is built in the schema Accounting. Adding the schema
name in front of the table name will solve the problem (Figure 12.8).
8. If Smith is logged on directly to the database Class_Registration, the default schema
is Accounting. In this case, no error will be generated when using only the table name
ACCOUNT. Let us log on as Smith as shown in Figure 12.9.
9. To show that Smith is a qualiied user to the schema Accounting, enter the SQL
statement
ALTER TABLE ACCOUNT ADD LastName CHAR(30)
shown in Figure 12.10 and execute it.
Since Smith's default schema is Accounting, using the table name ACCOUNT
without attaching the schema name does not generate an error.
Search WWH ::




Custom Search