The term invalid object is a database object referencing another object or objects that no longer exist in a database. For example, a stored procedure refers to a table deleted from the database. In this case, a stored procedure is an invalid object.
In dbForge Studio, you can use the Find Invalid Objects feature to search through a MySQL database schema to identify and recompile invalid objects, such as functions, procedures, triggers, and views.
The guide provides step-by-step instructions for the following topics:
1. Open the Find Invalid Objects window by using one of the following ways:
2. Specify the connection and select a database to search for invalid objects. In the Databases menu, you can:
3. Click Analyze to start searching.
Invalid objects are listed in a grid showing the type of database object, the schema it belongs to, its name, and the reason why it is deemed invalid. The preview pane displays the SQL script generated for the invalid object and also highlights the object that caused the selected object to be invalid.
In the Find Invalid Objects window, you can perform the following tasks:
Right-click the invalid object and select on the shortcut menu:
1. In the Find Invalid Objects grid, select the checkbox next to the required object.
2. On the toolbar, click Script as ALTER to generate the ALTER script for the object or Script as DROP to generate the DROP script for the object.
Note
To copy the script to the clipboard, click the down arrow next to Script as ALTER or Script as DROP and select To Clipboard.
3. By default, the script will open in a new SQL document.
dbForge Studio for MySQL has a built-in Command Line Wizard that converts the search options for invalid objects into command-line syntax and saves it as a *.bat file. You can then use this .bat file with a script and Windows Task Scheduler or any other task scheduler tool to schedule the search for invalid objects.
To open the Command Line Wizard, click Save Command Line on the toolbar.
The command line wizard has the following options:
Option | Description |
---|---|
Connection | Specify the connection string for the database to search for invalid objects. |
Password | Specify the server password. Note that it will override the values specified in the Connection parameter. |
Database | Specify the database to find invalid objects. You can specify either a single database or multiple databases separated by commas. Note that it will override the database specified in the Connection parameter. |
All databases | Select this option if you want to search for invalid objects in all non-system databases located on the server. |
Report | Specify a path to the report that will be generated in the CSV file format. |
Log | Specify a path to a log file. |
Echo OFF | Select this option to enclose all the text in the bat file in the @Echo OFF … @Echo ON construct. This will turn off the display of the commands being entered on the screen. |
Keep opened | Select this option to place the pause command at the end of the bat file text. This will leave the command window open. |
PowerShell | Select this option to generate the & symbol at the beginning of the bat file text. This will ensure the PowerShell compatibility. |
You can click Validate to verify the script.
You can search for invalid objects using command line.
1. Click Start, type cmd in the Search programs and files text box, and press ENTER. The Command Prompt opens.
2. Specify the operation you want to perform and the required parameters and arguments (actions you want to run) in the Command Prompt, for example as follows:
dbforgemysql.com/findinvalidobjects [/option_name1[:value | [parameter1:value parameter2:value ..]] /option_name2 ..]
3. Press ENTER to run the process.
4. Select corresponding command line switches to perform the required operations:
/connection: Specifies the connection string.
/connection:<connection_string>
/password: Specifies the server password and overrides the values specified in the /connection parameter.
/password:<pw>
/database: Specifies the database(s) and overrides the values specified in the /connection parameter. You can specify either a single database or multiple databases separated by commas.
/database:<dbname1[,dbname2]>
/alldatabases: Finds invalid objects for all non-system databases specified in the /connection parameter.
/alldatabases
/exitcodes: Displays the list of exit codes that can be returned by the command-line process.
/exitcodes
/log: Generates a log file and saves it to the specified folder.
/log:<filepath>
/report: Generates a report in the CSV file format.
/report:<filename>
/treatwarningaserror: Specifies the behavior for treating warnings. Yes: Treat all warnings as errors, and the subsequent behavior will be determined by the errormode option. No: Do not consider warnings as errors and continue the command line execution.
/treatWarningAsError:[Yes|No]
/errormode: Specifies the application behavior when encountering an error. Ignore: Ignore all errors and continue execution. Abort: Cancel execution if an error occurs.
/errormode:<ignore|abort>
Short keys: | Â | Â |
connection | = | c |
password | = | pwd |
database | = | db |
alldatabases | = | a |
report | = | r |
log | = | l |