Connection between MySQL stored procedures and databases

Source: Internet
Author: User

MySQL stored procedures are frequently used. The following describes the connection between MySQL stored procedures and databases in detail. If you are interested in MySQL stored procedures, take a look.

1. to convert a TABLE from one type to another, use the alter table statement, which indicates the New Type:
Alter table t ENGINE = MYISAM;
Alter table t TYPE = BDB;

Ii. MySQL stored procedure:

MySQL storage programs are particularly useful in the following situations:

1. When you write multi-customer applications in different languages, or multi-customer applications run on different platforms and need to perform the same database operations.

2. Security is critical. For example, a bank uses a storage program for all common operations. This provides a robust and secure environment for programs to ensure that every operation is properly logged. In such a setting, the application and the user cannot directly access the database table, but only the specified storage program can be executed. Stored programs and functions are subprograms created using the create procedure and create function statements. A sub-program is either a program or a function. Use the CALL statement to CALL a program. The program can only return values using output variables. Just like other function calls, a function can be called out of a statement by referencing the function name.) A function can return a scalar value. The storage subroutine can also call other storage subroutines.

In MySQL 5.1, a storage subroutine or function is associated with a specific database. Here are a few meanings:

1. When a subprogram is called, an implicit USE db_name is executed and the execution stops when the subprogram ends ). It is not allowed to store USE statements in subprograms.

2. You can use the database name to limit the subprogram name. This can be used to reference a subroutine that is not in the current database. For example, to reference a stored program p or function f associated with the test database, you can CALL test. p () or test. f ().

3. When the database is removed, all stored subroutines associated with it are also removed.

Example of creating a MySQL Stored Procedure

MySql stored procedure with Parameters

How to process MySQL record duplication

How to query time periods in MySql

How to back up and restore a MySQL database

Related Article

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.