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