Primary key issue when running Oracle sql file


 
Thread Tools Search this Thread
Operating Systems Solaris Primary key issue when running Oracle sql file
# 1  
Old 04-30-2014
Primary key issue when running Oracle sql file

I got a issue with running the following script below if I remove the inserts and alter table the tables will install just fine but if I try and do the full thing in one go i get the below error dose any one have any ideas on this problem?

its got me spinning, thanks.

Quote:
PRIMARY KEY (filename, type)
*
ERROR at line 3:
ORA-02260: table can have only one primary key
Code:
REM
REM List of audit trail file types.  This is for human consumption only and
REM is never referenced or modified by the servers.
REM
CREATE TABLE gam_file_types (
	type		NUMBER(2,0)
			PRIMARY KEY
			USING INDEX
				TABLESPACE gam_ind
				STORAGE (INITIAL 256K NEXT 256K PCTINCREASE 0
					MAXEXTENTS UNLIMITED),
	description	VARCHAR2(100)
) TABLESPACE gam_tab STORAGE (INITIAL 256K NEXT 256K PCTINCREASE 0
				MAXEXTENTS UNLIMITED);

INSERT INTO gam_file_types VALUES (1, 'Activity records');
INSERT INTO gam_file_types VALUES (2, 'User information modification records');
INSERT INTO gam_file_types VALUES (3, 'Host ID tracking records');

REM
REM List of currently existing audit trail files.  This table is populated
REM by the MCP and updated by the gobbler.
REM
CREATE TABLE gam_files (
	filename	VARCHAR2(60)
			NOT NULL,
	type		NUMBER(2,0)
			NOT NULL,
	state		NUMBER(1)
			NOT NULL,
	created_time	NUMBER(20)
			NOT NULL,
	proc_start_time	NUMBER(20)
			NOT NULL,
	record_count	NUMBER(10)
			NULL
) TABLESPACE gam_tab STORAGE (INITIAL 256K NEXT 256K PCTINCREASE 0
				MAXEXTENTS unlimited);

ALTER TABLE gam_files ADD (CONSTRAINT gam_files_pk
	PRIMARY KEY (filename, type)
	USING INDEX TABLESPACE gam_ind STORAGE (INITIAL 256K NEXT 256K PCTINCREASE 0
			MAXEXTENTS unlimited)
);

# 2  
Old 04-30-2014
Mate,

In oracle one table can have maximum one primary key as coloumn.

Please check your scripts where you have primary key on coloumn while creating it and whether you are adding one more primary key by altering the same table..

Also please paste you whole code so that i will tell you where the exact error is...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

2. Shell Programming and Scripting

Issue with quotes when running SQL command from within su -c

RHEL 6.2/Bash shell root user will be executing the below script. It switches to oracle user logs in using sqlplus and tries to run the below UPDATE statement. All the commands after su -c are enclosed in a single quote delimited by semicolon. The execution has failed because the quotes... (3 Replies)
Discussion started by: omega3
3 Replies

3. Programming

Identifying a missing primary key

I have the following method to identify missing primary keys in a MySQL database schema: USE information_schema; SELECT xx.table_name FROM (SELECT table_name, COUNT(*) FROM columns WHERE table_schema = @myDB GROUP BY table_name, column_key) xx GROUP BY xx.table_name HAVING COUNT(*) = 1; I... (0 Replies)
Discussion started by: figaro
0 Replies

4. Shell Programming and Scripting

Capture rows for a column in file from delete sql -Oracle

Hi, This may not be the right forum but i am hoping someone knows an answer to this. I have to capture rows for a column that was deleted. How can i do that without having to write a select query? delete from myschema.mytable where currentdatetimestamp > columnDate this should delete 5... (4 Replies)
Discussion started by: jakSun8
4 Replies

5. Programming

MySQL auto_increment, primary key

Hello, I want to create a table in mysql database by loading the local file. I am confused with the auto_increment column (say Run_ID) that I want to set it as primary key. My questions are: 1) Do I need add this Run_ID in my file ready? then this does not make any sense to the auto_increment;... (5 Replies)
Discussion started by: yifangt
5 Replies

6. Shell Programming and Scripting

Running Oracle SQL from shell script

Hi, can anyone help me with this script please. I need the oracle command to go into the unix batch file. #!/bin/sh # A menu driven Shell script which has following options # for acmtoron@> # # # Exit # As per option do the job #---- while : do clear echo " A C M LOG MONITORING... (0 Replies)
Discussion started by: tinaaguilera
0 Replies

7. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

8. Shell Programming and Scripting

To call a Oracle sql file 1000 times

Hi Guys, Even though, i have called db2 sql file earlier, this is my first time to call a oracle sql file. I need to make a database(oracle) connection and then call the sql file in a loop. Can you please help me out. Thanks for your help and time. Regards, Magesh (4 Replies)
Discussion started by: mac4rfree
4 Replies

9. UNIX for Dummies Questions & Answers

Running file sql from shell without capture the password

Dear All I have file a.sql, let's say the content is: _________________________________ select * from dual; exit; _________________________________ and I have shell script a.sh, the content is: _________________________________ ORACLE_SID=testing; export ORACLE_SID... (0 Replies)
Discussion started by: Aditya Purwanto
0 Replies

10. Shell Programming and Scripting

SQL scripts not running, possible timeout issue?

I am a novice Unix scripter and need a little advice/help on a script I've written that's causing some problems. We are using Solaris 9 on a Sun box and the script is invoked with the korn shell. I have a two-part question: I wrote a shell script that calls and executes 3 separate sql scripts,... (3 Replies)
Discussion started by: E2004
3 Replies
Login or Register to Ask a Question