What is the role of stored procedures in creating views and indexes in databases?

Source: Internet
Author: User
A view can be viewed as a virtual table or storage query. Data that can be accessed through views is not stored in the database as unique objects. The SELECT statement is stored in the database. The result set of the SELECT statement constitutes the virtual table returned by the view. You can use the method used to reference a table to use a virtual table in a Transact-SQL statement by referencing the view name. You can use a view to implement any or all of the following functions:

Limit the user to a specific row in the table.
For example, only employees are allowed to see the rows that record their work in the work tracking table.

Restrict users to specific columns.
For example, employees who are not responsible for payroll processing can only see the name column, office column, work phone column, and department column in the employee table, you cannot see any columns that contain salary information or personal information.

Join the columns in multiple tables to make them look like a table.

Aggregate information instead of providing detailed information.
For example, display the sum of a column, or the maximum and minimum values of a column.
------------------
Indexes in databases are similar to those in books. In a book, you can use indexes to quickly find the required information without reading the entire book. In the database, the index allows the database program to find the required data without scanning the entire table.
------------------
Stored procedures make it easier to manage databases and display information about databases and users. A stored procedure is a pre-compiled set of SQL statements and optional control flow statements. It is stored in a name and processed as a unit. Stored procedures are stored in a database and can be executed by an application through a single call. They also allow users to declare variables, conditional executions, and other powerful programming functions.

Stored Procedures include program streams, logic, and queries to databases. They can accept parameters, output parameters, return one or more result sets, and return values.

Stored procedures can be used for any purpose of using SQL statements. They have the following advantages:

You can execute a series of SQL statements in a single stored procedure.

You can reference other stored procedures from your stored procedures, which simplifies a series of complex statements.

The stored procedure is compiled on the server when it is created, so it runs faster than a single SQL statement.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.