I'm unfamiliar w/ sql scripting. I need an example of an install script for a sql file. See script below.

I need an install script per the guidelines of the customer I'm working with. the simple code is:
TRUNCATE TABLE WEBINVMGR.TPAXAUDITSI;
TRUNCATE TABLE WEBINVMGR.TVSMAIN;

Open in new window


There some basic header info as well w/in this file but that's the truncation code that has worked already in dev. The package delivery is requiring an install package. Can someone provide a basic example? I am googling but usually I'm finding better results trying here first. Any assistance/guidance is appreciated.

thanks...
QuackdeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Much more context is required.

1) To execute the code above, you simply run mysql using a user/pass or ~/.my.cnf or /etc/mysql/debian.cnf for login credentials, so for example...

#!/bin/bash
mysql --defaults-extra-file=/etc/mysql/debian.cnf -e "TRUNCATE TABLE WEBINVMGR.TPAXAUDITSI;"
mysql --defaults-extra-file=/etc/mysql/debian.cnf -e "TRUNCATE TABLE WEBINVMGR.TVSMAIN;

Open in new window


2) By "header code", maybe you mean #!/bin/bash in a script of the mysql + defaults-extra-file. Unsure.

Clarify what "header code" might mean.

3) "The package delivery is requiring an install package."

This suggests you're attempting to create an installable package to place in a yum or apt-get repository.

You'll require providing much more context to comment about this.

4) Also describe the entire scope of what you're targeting to accomplish. Context is everything. The more context you provide, the more detailed + useful answers you'll receive.
0
QuackdeveloperAuthor Commented:
Thanks...sorry...new to this as I said. See answers below:


 2) By "header code", maybe you mean #!/bin/bash in a script of the mysql + defaults-extra-file. Unsure.

 Clarify what "header code" might mean. This is simply information regarding the project...dates, names...nothing to do with the actual script...disregard

 3) "The package delivery is requiring an install package."

The package would include the actual project.sql file along w/ the install script sql file, install.sql

4) Also describe the entire scope of what you're targeting to accomplish. Context is everything. The more context you provide, the more detailed + useful answers you'll receive.

The end goal is to delete the data w/in the tables but keep the tables. The script works w/in the dev environment but when this is handed off to a data base admin to run it in an alpha/prod environment they require the install script.

thanks for your  help.
0
QuackdeveloperAuthor Commented:
Also this will be called from sqlplus to run the script.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
I think the TRUNCATE commands above will empty your database correctly.

Place an update in this question as to whether it's resolved or you require additional assistance.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
QuackdeveloperAuthor Commented:
truncate worked as expected...thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.