Databases Reference
In-Depth Information
as tables. There are three basic commands that relate to object management. They
are as follows:
CREATE: used to create server and database objects, such as CREATE
TABLE and CREATE INDEX.
ALTER: used to modify server and database objects, such as ALTER
TABLE and ALTER INDEX.
DROP: used to delete server and database objects, such DROP TABLE
and DROP INDEX.
6.5.1 Using CREATE
The basic syntax of a CREATE command is:
CREATE objecttype objectname
commandoptions_and_parameters
The objectype is simply the type of object that you want to create, such as a
table, index, or view. The objectname uniquely identifies the object. The general
syntax of an object's fully qualified name in SQL Server 2005 is:
server.database.schema.object
What this means is, that in a SQL Server database, you can have only one object
of a particular name in a particular schema, which is used to organize database
objects. For xample, you could have a table named:
MyServ.OpsData.Sales.Employees
You could also have another table named:
MyServ.OpsData.Operations.Employees
Even though this would be allowed, because the table's fully qualified name is
different, it isn't recommended. It would be less confusing to create objects so
that each object has a unique, easily identifiable name. In this case, better table
names might be:
MyServ.OpsData.Sales.SalesEmployees
MyServ.OpsData.Operations.OperationsEmployees
Command options are somewhat command specific. Many are specified
through keywords, like the optional clauses in the SELECT statement. For exam-
ple, the CREATE TABLE command syntax lets you specify table columns and
data types. The CREATE INDEX command syntax, on the other hand, lets you
specify the source table and columns to use when creating an index. Some
options are supported across multiple commands, such as options that let you
specify the object's physical storage.
Search WWH ::




Custom Search