Shell extract MSYQL specified database The following table creates a statement as a single file

Source: Internet
Author: User

Dbcn= "mysql-h172.16.1.194-uroot-p123456";d b=dsp_ad_center;ii=0;ct= ' $DBCN-n-E "select COUNT (1) from Information_sch Ema. TABLES as t WHERE t.table_schema = ' $db ' and t.table_type = ' BASE TABLE '; "'; mkdir-p/chenenhui/$dbwhile true;doif [$ii-lt $ct]then p= $ii; let Ii++;echo p= $p echo ii= $iitable _name= ' $DBCN-E "Select CONCAT (T.table_schema, '. ', T.table_name) from INFORMATION_SCHEMA. TABLES as t where T.table_schema = ' $db ' and t.table_type = ' BASE TABLE ' limit $p, 1; " '; Echo table_name= $table _namesleep 0;ss= ' $DBCN-n-E "SHOW CREATE table $table _name;" ' Echo-e ' $ss >/chenenhui/$db/create_table_help.tsv ' $DBCN-e "CREATE table IF not EXISTS test.create_table_help (ta Ble_name varchar (+) Default ', Table_script varchar (+) Default ', XH INT auto_increment,primary KEY (XH)) CHARSET = u Tf8; TRUNCATE TABLE test.create_table_help; LOAD DATA LOCAL INFILE '//chenenhui//$db//create_table_help.tsv ' into table test.create_table_help CHARACTER SET UTF8; " ' ss_script= ' $DBCN-n -E "Select concat (case is XH = 1 then concat (' Use ', ' $db; ', char (TEN)) ELSE table_name END, table_script) from test . create_table_help; " ' Echo-e ' $ss _script ">/chenenhui/$db/$table _name.sqlecho"; ">>/chenenhui/$db/$table _name.sqlecho $table _ Nameelse Echo ' _while finished '; rm/chenenhui/$db/create_table_help.tsv ' $DBCN-n-E "DROP table IF EXISTS test.create_tab Le_help; " ' Exit 0;fidone

Shell extract MSYQL specified database The following table creates a statement as a single file

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.