Sponsored Content
Top Forums Programming Need help on Shell script for database maintainace.. Post 302370956 by ashokkumar.p on Friday 13th of November 2009 03:02:16 AM
Old 11-13-2009
Quote:
Originally Posted by TonyLawrence
Is the problem that you are not a postgres user?

su postgresuser commands

does that if you are root.

You could also use "sudo" to allow another user to be the postgres user for these commands; see Using sudo
Hi,

Thanks for the reply, My senario is given below..

Code:
[postgres@sys3 bin]$ ./postgres -D /usr/local/pgsql/data -O -P mydb
LOG:  database system was shut down at 2009-11-11 13:44:47 IST
LOG:  checkpoint record is at 0/AE63A0
LOG:  redo record is at 0/AE63A0; undo record is at 0/0; shutdown TRUE
LOG:  next transaction id: 2254; next oid: 17058
LOG:  database system is ready

POSTGRES backend interactive interface
$Revision: 1.307.2.1 $ $Date: 2003/01/01 21:57:18 $

backend> Reindex Database mydb
NOTICE:  relation 16416 was reindexed
NOTICE:  relation 1255 was reindexed
NOTICE:  relation 16410 was reindexed
NOTICE:  relation 1247 was reindexed
NOTICE:  relation 1249 was reindexed
NOTICE:  relation 1259 was reindexed
NOTICE:  relation 16388 was reindexed
NOTICE:  relation 16390 was reindexed
NOTICE:  relation 16392 was reindexed
NOTICE:  relation 16394 was reindexed
NOTICE:  relation 16396 was reindexed
NOTICE:  relation 16398 was reindexed
NOTICE:  relation 16400 was reindexed
NOTICE:  relation 16402 was reindexed
NOTICE:  relation 16404 was reindexed
NOTICE:  relation 16406 was reindexed
NOTICE:  relation 16412 was reindexed
NOTICE:  relation 16418 was reindexed
NOTICE:  relation 16594 was reindexed
NOTICE:  relation 16596 was reindexed
NOTICE:  relation 16598 was reindexed
NOTICE:  relation 16384 was reindexed
NOTICE:  relation 16386 was reindexed
NOTICE:  relation 16408 was reindexed
backend> LOG:  shutting down
LOG:  database system is shut down

In the above activity there is an interactive command "Reindex Database", I can't call this command in to a shell script. I want to do this activity without my interaction. Please suggest me what to do...

Last edited by vbe; 11-13-2009 at 05:44 AM.. Reason: added code tags...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can a shell script interact with database?

Hi All, Language like C,Java can interact with database..and can use database information .. can a shall script do this? if yes thn plz guide me..... thankx (7 Replies)
Discussion started by: johnray31
7 Replies

2. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

3. Shell Programming and Scripting

what is uses of unix shell script in database projects

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (2 Replies)
Discussion started by: alokjyotibal
2 Replies

4. Shell Programming and Scripting

How do I check using shell-script if an item is available in a database?

Input for the program is a text file consisting of n no. of items. I want search each item in a database and the existing parts should go to FOUND folder and the others should go to NOTFOUND folder. Pls help me in this. Thank u. (1 Reply)
Discussion started by: smarty86
1 Replies

5. Shell Programming and Scripting

Connection to database through shell script

Hi when i am calling the shell script with two parameter like id and date it works fine.But the same shell script is call by java application it gives the error as shown below Thu Jan 8 04:13:22 EST 2009|The Get Segment Process Failed: SP2-0306: Invalid option. Usage: CONN where <logon>... (1 Reply)
Discussion started by: ravi214u
1 Replies

6. Shell Programming and Scripting

get result from database into shell script

hi, I have a script that will logon to a database siebel and do the select query and then get the result in command prompt of unix.Below the script. #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties #set -x while read i do echo $i connect1=`sqlplus -silent... (1 Reply)
Discussion started by: ali560045
1 Replies

7. Shell Programming and Scripting

Connecting to oracle database from shell script

Hi all, I am satyakiran , i am new to the forum. i never done shell scripts for connecting to the data base (oracle) and fetching the data from the database( thru sql select statements ) i want to know 1. how to connect to the data base(oracle) using shell script 2. how to retrieve data... (8 Replies)
Discussion started by: satyakiran
8 Replies

8. Shell Programming and Scripting

Switch from one database to other using shell script

Hi all, This is my first ever post to any forum so, dont let this go in vain...........:) Here is the scenario........ I have logged into the unix where oracle_sid is initialized for some X database in the .profile. I have a unix script where some sql query which fetches data from X... (3 Replies)
Discussion started by: sachinkl
3 Replies

9. Shell Programming and Scripting

Shell Script to connect to the oracle database

Hi Unix Gurus, I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
Discussion started by: bshivali
8 Replies

10. Shell Programming and Scripting

How to connect to Oracle database using shell script?

Hi All, I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect. I have tried like below, cnt=`sqlplus -s /nolog << EOFSQL ... (3 Replies)
Discussion started by: pmotewar
3 Replies
REINDEX(7)							   SQL Commands 							REINDEX(7)

NAME
REINDEX - rebuild corrupted indexes SYNOPSIS
REINDEX { TABLE | DATABASE | INDEX } name [ FORCE ] INPUTS TABLE Recreate all indexes of a specified table. DATABASE Recreate all system indexes of a specified database. (User-table indexes are not included.) INDEX Recreate a specified index. name The name of the specific table/database/index to be reindexed. Table and index names may be schema-qualified. FORCE Force rebuild of system indexes. Without this keyword REINDEX skips system indexes that are not marked invalid. FORCE is irrelevant for REINDEX INDEX, or when reindexing user indexes. OUTPUTS REINDEX Message returned if the table is successfully reindexed. DESCRIPTION
REINDEX is used to rebuild corrupted indexes. Although in theory this should never be necessary, in practice indexes may become corrupted due to software bugs or hardware failures. REINDEX provides a recovery method. REINDEX also removes certain dead index pages that can't be reclaimed any other way. See the "Routine Reindexing" section in the manual for more information. If you suspect corruption of an index on a user table, you can simply rebuild that index, or all indexes on the table, using REINDEX INDEX or REINDEX TABLE. Note: Another approach to dealing with a corrupted user-table index is just to drop and recreate it. This may in fact be preferable if you would like to maintain some semblance of normal operation on the table meanwhile. REINDEX acquires exclusive lock on the ta- ble, while CREATE INDEX only locks out writes not reads of the table. Things are more difficult if you need to recover from corruption of an index on a system table. In this case it's important for the backend doing the recovery to not have used any of the suspect indexes itself. (Indeed, in this sort of scenario you may find that backends are crashing immediately at start-up, due to reliance on the corrupted indexes.) To recover safely, the postmaster must be shut down and a stand-alone PostgreSQL backend must be started instead, giving it the command-line options -O and -P (these options allow system table mod- ifications and prevent use of system indexes, respectively). Then issue REINDEX INDEX, REINDEX TABLE, or REINDEX DATABASE depending on how much you want to reconstruct. If in doubt, use REINDEX DATABASE FORCE to force reconstruction of all system indexes in the database. Then quit the standalone backend and restart the postmaster. Since this is likely the only situation when most people will ever use a standalone backend, some usage notes might be in order: o Start the backend with a command like postgres -D $PGDATA -O -P my_database Provide the correct path to the database area with -D, or make sure that the environment variable PGDATA is set. Also specify the name of the particular database you want to work in. o You can issue any SQL command, not only REINDEX. o Be aware that the standalone backend treats newline as the command entry terminator; there is no intelligence about semicolons, as there is in psql. To continue a command across multiple lines, you must type backslash just before each newline except the last one. Also, you won't have any of the conveniences of command-line editing (no command history, for example). o To quit the backend, type EOF (Control+D, usually). See the postgres(1) reference page for more information. USAGE
Recreate the indexes on the table mytable: REINDEX TABLE mytable; Rebuild a single index: REINDEX INDEX my_index; Rebuild all system indexes (this will only work in a standalone backend): REINDEX DATABASE my_database FORCE; COMPATIBILITY
SQL92 There is no REINDEX in SQL92. SQL - Language Statements 2002-11-22 REINDEX(7)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy