zoukankan      html  css  js  c++  java
  • A Walkthrough of SQL Schema

    A Walkthrough of SQL Schema

       This article gives an overview of SQL Schema and its usage in SQL Server.

    Introduction to Schema

    A SQL database contains multiple objects such as tables, views, stored procedures, functions, indexes, triggers. We define SQL Schema as a logical collection of database objects. A user owns that owns the schema is known as schema owner. It is a useful mechanism to segregate database objects for different applications, access rights, managing the security administration of databases. We do not have any restrictions on the number of objects in a schema.

    Starting from SQL Server 2005, we have different meanings of user and schema. Now, the database object owner is a schema, and we define schema owners. We can have a single or multiple schema owners. It provides the following benefits:

    • We can quickly transfer ownership of a SQL schema to another user
    • We can share a schema among multiple users
    • It allows you to move database objects among the schemas
    • We get more control over database objects access and security

    We define default SQL Schema for a database user in the create database user window: 

     If we do not define any default schema for a user, SQL Server assumes dbo as the default schema. We can verify the default schema for a user using the following system function: 

    Retrieve all schema and their owners in a database

    We can query sys.schemas system table to find out schema in a database and their owners: 

    In the following screenshot, we can see master database schema and their owners: 

    SQL Schema is a database entity, and you might get a different result of the query in a user database. For example, the AdventureWorks database shows the following schema information:

    Note: SQL Server does not allow users to create objects in sys and INFORMATION_SCHEMA. It is used for storing internal system objects.

    Conclusion

    A SQL schema is a useful database concept. It helps us to create a logical grouping of objects such as tables, stored procedures, and functions.  

  • 相关阅读:
    vs2013配置opencv2.4.13(txt中复制粘贴即可,一次配置永久使用)
    描述性统计量
    Ubuntu创建、删除文件与目录
    Linux下服务器端开发流程及相关工具介绍(C++)
    TCP 协议如何保证可靠传输
    真实记录疑似Linux病毒导致服务器 带宽跑满的解决过程
    Windbg程序调试--转载
    原来问题在这里-我的memory leak诊断历程
    用WinDbg分析Debug Diagnostic Tool生成的Userdump文件
    一个内存增长问题的分析和处理(三)
  • 原文地址:https://www.cnblogs.com/chucklu/p/14889148.html
Copyright © 2011-2022 走看看