What exactly mean by schema? Can store开发者_运维百科d procedures and tables have different schema ? How can i specify structure through schema? is stored peoceduer identify object through scheme?
Schema refers to database tables and how them are related to each other. Stored procedures are also part of the database, but not of the schema.
Read more http://en.wikipedia.org/wiki/Database_schema
UPDATED: Stored procedures are incorrectly mentioned as not part of a database schema.
The answer of onedaywhen is the right one.
It is subjective. Wikipedia tell us,
In a relational database, the schema defines the tables, fields, relationships, views, indexes, packages, procedures, functions, queues, triggers, types, sequences, materialized views, synonyms, database links, directories, Java, XML schemas, and other elements.
..which is at odds with @niktrs's answer because he explicitly exclude's procedures from the schema.
Often I've had to enforce a database constraint for which the DBMS has no support (e.g. would require a subquery in a CHECK
constraint) and I've resorted to removing update permissions from the base table and provding a 'helper' stored proc that must be used to update the table. In these circusmtances I could argue that the stored proc forms part of the schema.
On a practical note, if on SO I requested of a questioner, "Please post your schema" and they posted their stored proc (if it was relevant to the question) then I for one wouldn't complain ;)
Schema in SQL Server is like "namespace" in .net. It's only been implemented correctly since SQL Server 2005 so I won't go into ancient history
Schema also refers to the table definitions, keys etc in common use. This is what you mean by "structure" I guess. This meaning is separate and different the namespace sense
Schema in the namespace sense means you can have a tables in, say, a Data schema but stored procedures in a WebGUI schema or Desktop schema. The WebGUI.GetOrders will refer to the Data.Order table.
One advantage of this is security is easier: you GRANT on the schema not on Objects
精彩评论