Get the App
SLTechnology News&Howtos  ›  Database  › 

How to write the sql statement of a single stored procedure exported by mysql

Shulou Source: shulou.com Published: 2022-06-01 02:43:28 10月28日 Update

Editor to share with you how to write the sql statement that mysql exports a single stored procedure. I hope you will gain a lot after reading this article. Let's discuss it together.

In mysql, you can use the "mysqldump-uroot-p-hlocalhost-P3306-n-d-t-R DBName > procedurename.sql" statement to export a single stored procedure.

View the contents of the specified stored procedure:

Select body from mysql.proc where name='procedurename'

View all stored procedures:

Show procedure status

Export stored procedures for MySQL

Mysqldump-uroot-p-hlocalhost-P3306-n-d-t-R DBName > procedurename.sql

Parameter description:

-n:-- no-create-db

-d:-- no-data

-t:-- no-create-info

-R:-- routines Dump stored routines (functions and procedures)

Introduction of main parameters:

Character set option

-- default--character-set=xx

Connection option

-uthmum, Murphy, username,

-pmam Musi passwordroomname

-hmm. color, color, etc.

-PMAE, music, and portals #

Output content options

-- add-drop-database

-- add-drop-table

-ntra, muri, no, create, db.

-ditto, murmur, Murphy, data

-t / t / m / w / w / b / w / w / w

Output format option

-- compact

-c-- complete-insert

-T (specify that the data in the data table is backed up as two files: simple data file and table SQL)

Note the xx.sql table creation file is created by root users of linux

The xx.txt file is created by a linux mysql user.

Therefore, the storage path of these two files must ensure that mysql users have permission to read, write and create files.

-- fields-terminated-by=name (domain delimiter)

-- fields-enclosed-by=name (domain reference)

-- fields-optionally-enclosed-by=name (optional characters for domain references)

-- fields-escaped-by=name (escape character)

Other

-F-- flush-logs (refresh log before backup)

-l-- lock-tables (add read locks to all tables)

Import stored procedures for MySQL

Mysql-hhostname-uusername-ppassword databasename < backupfile.sql after reading this article, I believe you have some understanding of how to write the sql statement of a single stored procedure exported by mysql. You want to know more about it. Welcome to follow the industry information channel. Thank you for reading!

Tags: Procedure storage file single statement character data user two content parameter backup article output delimiter character set done data backup data table log Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Shulou Technology Shulou Tech Info MariaDB