MySQL Database bulk modify tables in the database

Source: Internet
Author: User

Problem: Today's work encountered such a problem, need to put all the tables in the database, each table to add four fields, if the table is small, we can manually add or modify, if it is thousands of tables, how we go to modify, now recorded.

solutions;

Find the database modeling data, is the PDM file. Send a

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6F/21/wKiom1WSVuSCvKWmAAUI7VzUv-Y865.jpg "title=" Qq20150630164336.jpg "alt=" Wkiom1wsvuscvkwmaaui7vzuv-y865.jpg "/>


Now we're going to use a tool, which is powerdesign, and we'll use this tool to bulk modify the fields in the database table. Need to use VB Script.

We open the Powerdesign, click the script to run the bar, methods, tools--

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/1F/wKioL1WSW86wjGghAAXDpALm8E4613.jpg "title=" Qq20150630164336.jpg "alt=" Wkiol1wsw86wjgghaaxdpalm8e4613.jpg "/>

Click on the Run script box below 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/6F/22/wKiom1WSWmvzGm65AALp9DStAxE582.jpg " Title= "Qq20150630164336.jpg" alt= "Wkiom1wswmvzgm65aalp9dstaxe582.jpg"/> written script to run on it.

VB syntax


Option Explicit  
 
Dim MDL ' the current model     
Set mdl = Activemodel &nbs P
Dim Tab ' Running table     
Dim col_modtime, Col_modperson  
' define attribute variable  
for Each Tab in Activemodel.tables  
 set col_modtime = Tab.Columns.CreateNew  
 set Col_ Modperson = Tab.Columns.CreateNew  
 
     col_modtime.name = "Operation type"  
& nbsp;    Col_modtime.code = "Log_czlx"  
     col_modtime.datatype = "Char (1) " 
      
     col_modperson.name =" Time " 
     Col_modperson.code = "LOG_CZSJ"  
     col_modperson.datatype = "Datatime ()"
Next

---------------------------I'm the perfect dividing line-----------------------------------------

Option Explicit
Dim MDL ' The current model
Set mdl = Activemodel
Dim Tab ' Running table
Dim COL_MODLOG_SC, Col_modlog_xz
' Define attribute variables
For all Tab in Activemodel.tables
Set COL_MODLOG_SC = Tab.Columns.CreateNew
Set col_modlog_xz = Tab.Columns.CreateNew

Col_modlog_sc.name = "Upload Status"
Col_modlog_sc.code = "LOG_SC"
Col_modlog_sc. DataType = "Char (1)"

Col_modlog_xz.name = "Download Status"
Col_modlog_xz.code = "Log_xz"
Col_modlog_xz. DataType = "Char (1)"
Next


The above script inserts four fields into each data table in the database.

Complete the above, you have completed a large part of the task of work. After the insert is complete you want to save, then export TXT file or SQL file, I am exporting txt.

Methods are as follows


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/22/wKiom1WSXECwDMyjAAV7QP2YbzU840.jpg "title=" Qq20150630164336.jpg "alt=" Wkiom1wsxecwdmyjaav7qp2ybzu840.jpg "/>

You can export.

Or you can choose to paste it out and see the script that creates the data table inside

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/1F/wKioL1WSXo6CafoGAAU7MukwqRw551.jpg "title=" Qq20150630164336.jpg "alt=" Wkiol1wsxo6cafogaau7mukwqrw551.jpg "/>

The latter is to modify the things you want to modify, such as replacing the original things, we can use this tool. UltraEdit

This article is from "Ghost" blog, please make sure to keep this source http://fangwei009.blog.51cto.com/5234706/1669474

MySQL Database bulk modify tables in the 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.