LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 10-28-2007, 05:52 AM   #1
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Rep: Reputation: 36
Question sql*plus


Hi all,

I have recently installed oracle database 10g express edition on
ubuntu dapper. I am running sql*plus via

Applications ->Oracle database 10g express edition -> Run sql command line

now my question is how to run sql*plus in virtual console window??
or which is the executable file for sql*plus ???
 
Old 10-28-2007, 09:59 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
As I understand the question, you want to run sqlplus from the command line.

So long as your environment variables are set up correctly, all you should need is to type sqlplus.

However, if you want to run this from another machine, that machine would need to have the Oracle client components installed on it. Additionally you would need to have tnsnames.ora file configured with the information about the database instance you want to connect to.

Environment variables to consider are:
ORACLE_HOME (location Oracle has been installed to)
ORACLE_SID (database that you want to connect to)
NLS_DATE_FORMAT (Format Oracle will display dates in)

Ensure that the PATH variable contains $ORACLE_HOME/bin
 
Old 10-29-2007, 09:44 AM   #3
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Original Poster
Rep: Reputation: 36
Question

Quote:
Originally Posted by Disillusionist View Post
As I understand the question, you want to run sqlplus from the command line.

So long as your environment variables are set up correctly, all you should need is to type sqlplus.

However, if you want to run this from another machine, that machine would need to have the Oracle client components installed on it. Additionally you would need to have tnsnames.ora file configured with the information about the database instance you want to connect to.

Environment variables to consider are:
ORACLE_HOME (location Oracle has been installed to)
ORACLE_SID (database that you want to connect to)
NLS_DATE_FORMAT (Format Oracle will display dates in)

Ensure that the PATH variable contains $ORACLE_HOME/bin
how to change the path variable???.
which file i have to edit??
(is it in /etc/rc2.d ???)

if i remember correctly i think in windows we have to edit autoexec.bat file and add the the line path=%path%;ORACLE_HOME/bin
(correct me if i am wrong)
 
Old 10-29-2007, 02:35 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
When you installed Oracle 10g Express Edition the install will have created a user called oracle

Initial setup:
1. Change / set the password for that account: sudo passwd oracle

2. Log in as the oracle account: su - oracle

3. vi .profile:
Code:
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_SID=XE
export PATH=$ORACLE_HOME/bin:$PATH
Then when you login as oracle (su - oracle) your environment will be set


Not sure what level of experience you have with Oracle so forgive me if I am explaining things that you already know.


To gain admin access the the XE database (created by default with Express Edition):
Code:
sqlplus '/ as sysdba'
you can then modify the sys password (example to set the sys account to "newpassword"):
Code:
alter user sys identified by newpassword;
 
Old 10-30-2007, 11:37 PM   #5
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Original Poster
Rep: Reputation: 36
Thumbs up

Thanks a lot. your information was quite useful
 
Old 11-04-2007, 09:09 AM   #6
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Original Poster
Rep: Reputation: 36
Question

Quote:
Originally Posted by sulekha View Post
Thanks a lot. your information was quite useful
what about stopping oracle database from command line???
 
Old 11-04-2007, 10:25 AM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
log in as the oracle account, and use the shutdown command in sqlplus:
Code:
su - oracle
sqlplus '/ as sysdba'
shutdown
There are variations on the shutdown command
shutdown
shutdown immediate
shutdown abort

"shutdown" waits for any active processes to finish before stopping the database.

"shutdown immediate" asks active processes to finish and then stops the database once they have completed.

"shutdown abort" forces the database to stop and kills any active processes

The first two options are much cleaner as active processes are closed cleanly.

The last option is occasionally necessary, when a process is not stopping.

Oracle is pretty good at cleaning up any mess left from a shutdown abort, but it's not good practice to just go straight to shutdown abort.

Hope this helps
 
Old 11-17-2007, 08:54 PM   #8
landonmkelsey
Member
 
Registered: Jul 2001
Location: Texas
Distribution: Fedora 16
Posts: 323

Rep: Reputation: 37
need a simple SQL script run on Oracle

Once under Oracle this script resulted in empty tables

but not under mysql or MS SQL Server 2005


client for mysql is 100000 times better than sql*plus
I once threatened to rewrite sql*plus
_____________________________

alter table pets_like_boys
drop constraint pets_like;

alter table girls_like_pets
drop constraint girls_like;

alter table boys_like_girls
drop constraint boys_like;

drop table pets_like_boys;
drop table boys_like_girls;
drop table girls_like_pets;
- .............start here the first time

create table pets_like_boys (pets_name varchar(32), boys_name varchar(32),primary key (pets_name));
create table boys_like_girls (boys_name varchar(32), girls_name varchar(32),primary key (boys_name));
create table girls_like_pets (girls_name varchar(32), pets_name varchar(32),primary key (girls_name));

insert into pets_like_boys values('fluffy', 'sam');
insert into pets_like_boys values('rover', 'bob');
insert into pets_like_boys values('skippy', 'joe');

insert into boys_like_girls values('bob','jill');
insert into boys_like_girls values('sam','betty');
insert into boys_like_girls values('joe','sue');
insert into boys_like_girls values('george','jill');

insert into girls_like_pets values('sue','fluffy');
insert into girls_like_pets values('jill','skippy');
insert into girls_like_pets values('betty','rover');

alter table pets_like_boys
add constraint pets_like
foreign key (boys_name )
references boys_like_girls
on delete cascade;

alter table boys_like_girls
add constraint boys_like
foreign key (girls_name )
references girls_like_pets
on delete cascade;

alter table girls_like_pets
add constraint girls_like
foreign key (pets_name )
references pets_like_boys
on delete cascade;


select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
delete from boys_like_girls where boys_name = 'bob';
select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;



select table_name from user_tables;
 
Old 11-26-2007, 02:00 PM   #9
landonmkelsey
Member
 
Registered: Jul 2001
Location: Texas
Distribution: Fedora 16
Posts: 323

Rep: Reputation: 37
on Oracle the tables are emptied...example of the dangers of cascade

from the otn.oracle.com forum
Hi,


TEST@XE> create table pets_like_boys (pets_name varchar(32), boys_name varchar(32),primary key (pets_name));

Table created.

TEST@XE> create table boys_like_girls (boys_name varchar(32), girls_name varchar(32),primary key (boys_name));

Table created.

TEST@XE> create table girls_like_pets (girls_name varchar(32), pets_name varchar(32),primary key (girls_name));

Table created.

TEST@XE> insert into pets_like_boys values('fluffy', 'sam');

1 row created.

TEST@XE> insert into pets_like_boys values('rover', 'bob');

1 row created.

TEST@XE> insert into pets_like_boys values('skippy', 'joe');

1 row created.

TEST@XE> insert into boys_like_girls values('bob','jill');

1 row created.

TEST@XE> insert into boys_like_girls values('sam','betty');

1 row created.

TEST@XE> insert into boys_like_girls values('joe','sue');

1 row created.

TEST@XE> insert into boys_like_girls values('george','jill');

1 row created.

TEST@XE> insert into girls_like_pets values('sue','fluffy');

1 row created.

TEST@XE> insert into girls_like_pets values('jill','skippy');

1 row created.

TEST@XE> insert into girls_like_pets values('betty','rover');

1 row created.

TEST@XE> alter table pets_like_boys add constraint pets_like foreign key (boys_name) references boys_like_girls on delete cascade;

Table altered.

TEST@XE> alter table boys_like_girls add constraint boys_like foreign key (girls_name) references girls_like_pets on delete cascade;

Table altered.

TEST@XE> alter table girls_like_pets add constraint girls_like foreign key (pets_name) references pets_like_boys on delete cascade;

Table altered.

TEST@XE> select * from pets_like_boys;

PETS_NAME BOYS_NAME
-------------------------------- --------------------------------
fluffy sam
rover bob
skippy joe

TEST@XE> select * from boys_like_girls;

BOYS_NAME GIRLS_NAME
-------------------------------- --------------------------------
bob jill
sam betty
joe sue
george jill

TEST@XE> select * from girls_like_pets;

GIRLS_NAME PETS_NAME
-------------------------------- --------------------------------
sue fluffy
jill skippy
betty rover

TEST@XE> delete from boys_like_girls where boys_name = 'bob';

1 row deleted.

TEST@XE> select * from pets_like_boys;

no rows selected

TEST@XE> select * from boys_like_girls;

no rows selected

TEST@XE> select * from girls_like_pets;

no rows selected


Cheers
 
Old 11-27-2007, 08:13 AM   #10
landonmkelsey
Member
 
Registered: Jul 2001
Location: Texas
Distribution: Fedora 16
Posts: 323

Rep: Reputation: 37
I was wrong..this does work under mysql

drop table pets_like_boys;
drop table boys_like_girls;
drop table girls_like_pets;

create table pets_like_boys (pets_name varchar(32), boys_name varchar(32),primary key (pets_name)) type=innodb;
create table boys_like_girls (boys_name varchar(32), girls_name varchar(32),primary key (boys_name)) type=innodb;
create table girls_like_pets (girls_name varchar(32), pets_name varchar(32),primary key (girls_name)) type=innodb;

insert into pets_like_boys values('fluffy', 'sam');
insert into pets_like_boys values('rover', 'bob');
insert into pets_like_boys values('skippy', 'joe');

insert into boys_like_girls values('bob','jill');
insert into boys_like_girls values('sam','betty');
insert into boys_like_girls values('joe','sue');
insert into boys_like_girls values('george','jill');

insert into girls_like_pets values('sue','fluffy');
insert into girls_like_pets values('jill','skippy');
insert into girls_like_pets values('betty','rover');

alter table pets_like_boys add constraint pets_like foreign key (boys_name) references boys_like_girls(boys_name) on delete cascade;
alter table boys_like_girls add constraint boys_like foreign key (girls_name) references girls_like_pets(girls_name) on delete cascade;
alter table girls_like_pets add constraint girls_like foreign key (pets_name) references pets_like_boys(pets_name) on delete cascade;

select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
delete from boys_like_girls where boys_name = 'bob';
select * from pets_like_boys;
select * from boys_like_girls;
select * from girls_like_pets;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sql - stored procedures, views, and dynamic sql generation LXer Syndicated Linux News 0 08-17-2006 06:33 AM
SQL: old sql dump not loading into new db BrianK Linux - Software 1 07-25-2006 11:55 PM
Migrating from MS-SQL server to My-SQL emailssent Linux - Networking 2 02-07-2005 02:20 PM
Which SQL is suitable for EMbedded SQL on C? hk_michael Programming 4 01-10-2005 05:07 PM
sql k3v0 Linux - Software 2 12-26-2002 04:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration