• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 53
  • Last Modified:

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...
0
Quack
Asked:
Quack
  • 3
  • 2
1 Solution
 
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
 
QuackdeveloperAuthor Commented:
truncate worked as expected...thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now