Through custom scripting you could create a script to do it, however this is over the head of 90% of users who run websites.

Generally it's easier to stick to using the MySQL command line for running commands through your server; this would be as easy as:
1. Login to the Server via SSH or Telnet (I very much hope that the later is disabled on your machine for security).
2. Login to the MySQL command line:
Code
mysql -hlocalhost -uusername -p
This should first ask you for your password, and then drop you to the MySQL command line.
3. Issue the command to use the table of your choice:
Code
use my_database;
4. Issue the command of your choice; for this example, optimizing your UBB7 tables:
Code
OPTIMIZE TABLE `ubb7_ADDRESS_BOOK` , `ubb7_ADMIN_SEARCHES` , `ubb7_ANNOUNCEMENTS` , `ubb7_BANNED_EMAILS` , `ubb7_BANNED_HOSTS` , `ubb7_BANNED_USERS` , `ubb7_CACHE` , `ubb7_CACHED_PERMISSIONS` , `ubb7_CALENDAR_EVENTS` , `ubb7_CAPTCHA` , `ubb7_CATEGORIES` , `ubb7_CENSOR_LIST` , `ubb7_DISPLAY_NAMES` , `ubb7_fc_bans` , `ubb7_fc_config` , `ubb7_fc_config_chats` , `ubb7_fc_config_instances` , `ubb7_fc_config_values` , `ubb7_fc_connections` , `ubb7_fc_ignors` , `ubb7_fc_messages` , `ubb7_fc_rooms` , `ubb7_FILES` , `ubb7_FORUMS` , `ubb7_FORUM_LAST_VISIT` , `ubb7_FORUM_PERMISSIONS` , `ubb7_GRAEMLINS` , `ubb7_GROUPS` , `ubb7_IMPORT_MAP` , `ubb7_LANGUAGES` , `ubb7_MAILER` , `ubb7_MEMBER_SEARCHES` , `ubb7_MODERATORS` , `ubb7_MODERATOR_NOTIFICATIONS` , `ubb7_MODERATOR_PERMISSIONS` , `ubb7_ONLINE` , `ubb7_POINTER_DELETE` , `ubb7_POLL_DATA` , `ubb7_POLL_OPTIONS` , `ubb7_POLL_VOTES` , `ubb7_PORTAL_BOXES` , `ubb7_POSTS` , `ubb7_PRIVATE_MESSAGE_POSTS` , `ubb7_PRIVATE_MESSAGE_TOPICS` , `ubb7_PRIVATE_MESSAGE_USERS` , `ubb7_RATINGS` , `ubb7_REGISTRATION_FIELDS` , `ubb7_RESERVED_NAMES` , `ubb7_RSS_FEEDS` , `ubb7_SAVED_QUERIES` , `ubb7_SEARCH_AGENTS` , `ubb7_SEARCH_RESULTS` , `ubb7_SHOUT_BOX` , `ubb7_STYLES` , `ubb7_TOPICS` , `ubb7_TOPIC_VIEWS` , `ubb7_USERS` , `ubb7_USER_DATA` , `ubb7_USER_GROUPS` , `ubb7_USER_NOTES` , `ubb7_USER_PROFILE` , `ubb7_USER_TITLES` , `ubb7_VERSION` , `ubb7_WATCH_LISTS`;
5. When the above query is done, to exit mysql issue:
Code
\q


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!