Showing posts with label sqlplus. Show all posts
Showing posts with label sqlplus. Show all posts

Monday, August 10, 2009

SQL*PLUS KULLANIM KLAVUZU

Çok güzel br şeklide anlatmişlar. bağlantılı linklere bakarak sql*plus'ı daha etkili bir şekilde kullanabilirsiniz.

http://arjudba.blogspot.com/2008/11/sqlplus-basics-and-tips.html

Friday, August 7, 2009

SQL*PLUS da PROMPT AYARLARI

Bu yazımızda birazda SQL-plus magazin yapalım. Süsleme ile ilgli birkaç şey yazalım diyeceğim. Aslında süslemeden ziyade hangi user ile hangi işlemi yaptığımız göreceğiz diyebiliriz. yada ne zaman çalışmaya başladığını sorgunun ne kadar süredir çalıştıgını buradan kolay yoldan gözlemleyebiliriz.
Aslında işin espirisi SQL*plus da default olarak gelen SQL> ifadesinin yerine istediğimizi yazmak. Buraya sysdate i ekelyerek sorguların zamanını user ekleyerek userı _connect_identifier ekleyerek hangi schemaya bağlı olduğumu görebiliriz.

Örnek uygulamalar

SYS on 08/07/2009 16:02:52 at orcl >set sqlprompt "_user>"
SYS>
SYS>set sqlprompt "_user _date>"
SYS 08/07/2009 16:04:00>
--zamanı ekledik
--zaman formatını değiştirmek için
SYS 08/07/2009 16:06:19>alter session set nls_date_format = ‘mm/dd/yyyy’;

Oturum de­i■tirildi.

SYS 08/07/2009> set sqlprompt “_user 'userı' _connect_identifier 'bağlandı'>"
SYS userı orcl bağlandı>
--aralara stringler yazarak işi eğlenceli hale getirebilir arkadaşlarına hava atabilrsiniz.

hepinize iyi eğlenceler.

kaynak :http://arjudba.blogspot.com/2008/11/sqlplus-basics-and-tips.html

Friday, June 5, 2009

SET DEFINE ON OFF

Bu yazıda pl sql kodlarında sürekli karşımıza çıkan set define komutunun kullanımı ile ilgili örnekler vereceğim.
set define on
select '&hello' from DUAL;
Dediğimiz zaman & karakteri bize klavyeden değer girmemizi isteyecektir.
Enter value for hello: this string was entered
old 1: select '&hello' from dual
new 1: select 'this string was entered' from dual

'THISSTRINGWASENTERED'
-----------------------
this string was entered

/*****************************************************/
set define off dediğimiz zaman & karakterini bir string olarak algılayacaktir.
Dinamik SQL kullanırken işimize yaracak bir durumdur
set define off
select '&hello' from dual;
&hello

Tuesday, June 2, 2009

Enabling iSQL*Plus DBA Access

There are a couple of ways to protect the standard iSQL*Plus URL. One way is to use the default setup for the DBA URL and extend this to also protect the standard URL. The other way is to create a new role which protects just the standard URL. You will need to do this setup manually, and here's the instructions on how to do it.

I've written this using a Windows install, but the process is the same for other operating systems. Just change the % to $, and switch the to / in the paths.

Protect both the standard and DBA URLs using the webDba role

The webDba role is already configured in an Oracle database install to protect the DBA URL using basic authentication. To extend this same authentication to include the iSQL*Plus standard URL, perform the following steps:

  1. Edit %ORACLE_HOME%oc4jj2eeoc4j_applicationsapplicationsisqlplusisqlplusWEB-INFweb.xml to add another element:
    *

    Your element should now look like this:


    dba.uix


    /dba.uix
    /dbA.uix
    /dBa.uix
    /dBA.uix
    /Dba.uix
    /DbA.uix
    /DBa.uix
    /DBA.uix
    *

    DynamicDba


    /dba/dynamic


    webDba


    NONE

  2. From the directory %ORACLE_HOME%oc4jj2eeisqlplusapplication-deploymentsisqlplus, run the following commands:

    set ORACLE_HOME=
    set JAVA_HOME=%ORACLE_HOME%jdk
    cd %ORACLE_HOME%oc4jj2eeisqlplusapplication-deploymentsisqlplus

    Change to the location of your Oracle Home, for example, C:oracleprogramsora10g.

  3. Use JAZN to add a user and assign it a role to access the iSQL*Plus URLs. This is the same as setting up the DBA URL described in the SQL*Plus documentation.

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -adduser "iSQL*Plus DBA" plusdba plusdba

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -grantrole webDba "iSQL*Plus DBA" plusdba

    If you want to use the JAZN shell, here's the equivalent commands:

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -shell

    JAZN>adduser "iSQL*Plus DBA" plusdba plusdba
    JAZN>grantrole webDba "iSQL*Plus DBA" plusdba
    JAZN>exit

    A little handy hint that I discovered while setting this up. If you use the JAZN shell, you need to exit the shell before any changes take place. I had a lot of frustration figuring out this procedure until I worked out this little feature!

    I didn't have to restart iSQL*Plus for this to take effect, but I did have to exit the JAZN shell.

  4. Test this has now been set up. Open a browser window and enter the iSQL*Plus URL:

    http://<;machine_name>:5560/isqlplus

    You should see an authentication dialog displayed. Enter plusdba/plusdba as your login. The iSQL*Plus login screen should be displayed. Close your browser (to remove the basic authentication), and do the same to test the iSQL*Plus DBA login:

    http://<;machine_name>:5560/isqlplus/dba

Protect the standard URL using a new role, and the DBA URL using the webDba role

The other way of setting up basic authentication for the iSQL*Plus standard URL, is to have two roles, one for the DBA URL, and one for the standard URL. So you can have one login for the DBA URL, which can also access the standard URL, and another login that can only access the standard URL.

As before, we reuse the webDba role which is already configured in an Oracle database install to protect the DBA URL. Then we create a new role to protect the iSQL*Plus standard URL. Here are the steps you need to perform:

  1. Edit %ORACLE_HOME%oc4jj2eeoc4j_applicationsapplicationsisqlplusisqlplusWEB-INFweb.xml to add the another element:

    login.uix


    *


    webUser
    webDba

    NONE

    And add another element:


    Privileged access to iSQL*Plus URL.
    webUser
  2. From the directory %ORACLE_HOME%oc4jj2eeisqlplusapplication-deploymentsisqlplus, run the following commands:

    set ORACLE_HOME=C:ora102
    set JAVA_HOME=%ORACLE_HOME%jdk
    cd %ORACLE_HOME%oc4jj2eeisqlplusapplication-deploymentsisqlplus

  3. Add a the role webUser to the "iSQL*Plus DBA" realm.
    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -addrole "iSQL*Plus DBA" webUser

    Add a user to the "iSQL*Plus DBA" realm.

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -adduser "iSQL*Plus DBA" plususer plususer

    Grant the role webUser to the plususer user.

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -grantrole webUser "iSQL*Plus DBA" plususer

    If you want to use the JAZN shell, here's the equivalent commands:

    %JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -shell

    JAZN>adduser "iSQL*Plus DBA" plususer plususer
    JAZN>addrole "iSQL*Plus DBA" webUser
    JAZN>grantrole webUser "iSQL*Plus DBA" plususer
    JAZN>exit
    I didn't have to restart iSQL*Plus for this to take effect, but I did have to exit the JAZN shell.

  4. Test this has now been set up. Open a browser window and enter the iSQL*Plus URL:

    http://<;machine_name>:5560/isqlplus

    You should see an authentication dialog displayed. Enter plususer/plususer as your login. The iSQL*Plus login screen should be displayed. Close your browser (to remove the basic authentication), and do the same to test the iSQL*Plus DBA login:

    http://<;machine_name>:5560/isqlplus/dba

The user you have just created, plususer, should be able to login to standard iSQL*Plus URL, but should not have access to the iSQL*Plus DBA URL.

When you create a user to access the iSQL*Plus DBA URL (as described in the SQL*Plus User's Guide and Reference), you should also grant the webUser role so it can access the standard iSQL*Plus URL.

Some Handy Commands

Just to add to this topic, I thought I'd add a few extra commands, to save you some typing, that you might need while setting all this up.

To stop iSQL*Plus:

%ORACLE_HOME%binisqlplusctl stop

To start iSQL*Plus:

%ORACLE_HOME%binisqlplusctl start

To remove the user plususer using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -remuser "iSQL*Plus User" plususer

To list the users using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -listusers

To list the realms using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -listrealms

To create the user plusdba in the "iSQL*Plus DBA" realm using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -adduser "iSQL*Plus DBA" plusdba plusdba

To grant the role webDba to the plusdba user using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -grantrole webDba "iSQL*Plus DBA" plusdba

To grant the role webUser to the plusdba user using JAZN:

%JAVA_HOME%binjava -Djava.security.properties=%ORACLE_HOME%oc4jj2eehomeconfigjazn.security.props -jar %ORACLE_HOME%oc4jj2eehomejazn.jar -user "iSQL*Plus DBA/admin" -password welcome -grantrole webUser "iSQL*Plus DBA" plusdba

alıntıdır. kaynak :Alison Holloway's Blog :

SQL*Plus Editing Commands

Command Abbreviation Purpose
APPEND text
A text

adds text at the end of the current line

CHANGE/old/new
C/old/new

changes old to new in the current line

CHANGE/text
C/text

deletes text from the current line

CLEAR BUFFER
CL BUFF

deletes all lines

DEL

(none)

deletes the current line

DEL n

(none)

deletes line n

DEL *

(none)

deletes the current line

DEL n *

(none)

deletes line n through the current line

DEL LAST

(none)

deletes the last line

DEL m n

(none)

deletes a range of lines (m to n)

DEL * n

(none)

deletes the current line through line n

INPUT
I

adds one or more lines

INPUT text
I text

adds a line consisting of text

LIST
; or L

lists all lines in the SQL buffer

LIST n
L n or n

lists line n

LIST *
L *

lists the current line

LIST n *
L n *

lists line n through the current line

LIST LAST
L LAST

lists the last line

LIST m n
L m n

lists a range of lines (m to n)

LIST * n
L * n

lists the current line through line n

sql*plus da yardımcı olabilecek bazı programlar ve çalıştırılmaları

edit komutu ile windows sistemlerde notepad açiliyor. unix sistemlerde ise bunu siz belirliyorsunuz.

unix, linux sistemlerde düzenleme programini

SQL> DEFINE _EDITOR = /bin/vi komutu ile belirleyebiliyorsunuz.

isql*plus da çalişmiyor. orada windos komutları kullanarak kopyala yapiştir yapabilir yada load script -butonunu kullanibilirsiniz.

sql*plus'da verilen hatalar ve bu hatalar ile ilgili çözüm yollari. direct bir faydasi olacağini düşünmüyorum ama can sıkıntısına okunabilir. önceden ing sözluk okuyordum hazirlik sinifinda şimdi ing sözluk okur gibi bu hata mesajlarını okuyabilirim ve ne tip hatalar oldugunu anlarim.(Bunları oturup okuyacağimi sanmıyorum :((( .) http://download.oracle.com/docs/cd/B10501_01/server.920/a90842/ch14.htm

iSQL*PLUS BAĞLANTILARI

isql*plus bilindiği üzere oracle kurulumu ile beraber sisteminize gelen sql sorgulama yapmanıza imkan veren arayüzdür.

Temel olarak sql*plus ile isql*plus arasında çok fazla fark yoktur.

iSQL*PLUS programına bağlantının nasıl yapılacağını anlatmak istiyorum.

http:// machine_name . domain: port/isqlplus bunu browsere yazarak bağlanırsınız.

ben kendi bilgisayarımda

http://aliates-cbh40oz:5561/isqlplus/ adresinden bağlaniyorum. şimdi siz buradan DBA olarak bağlanmak isteyebilirsiniz. ama bunu yapmak konsoldaki kadar basit değil burada. EM ye girerek bir kullanıcı oluşturmalisiniz yada var olan kullanıcılarından birisini lock durumundan unlock durumuna getirerek kulanıma hazirlarsiniz.

ben HR kullanıcısını kullanıyorum. Örnek resimde system kullanıcı var bizim için şimdilik o muhim değil.

resimde de görüşdüğü gibi connect identifier oalrak insr1 değeri girilmiş. bilgisayarımızda bir tane veritabanı var ise buraya bir değer girmemize gerek yok default olarak açilacaktir. Eğer birden fazla veritabanı var ise bu durumda hangisine bağlanmak istediğimizi belirtmeliyiz.

DBA olarak veritabanına girmek istersek giriş adresine ufak bir ekleme yapmaliyiz.

http:// machine_name . domain: port/isqlplus/dba

DBA alarak iSQL*PLUS üzerinden veritabanına bağlanmak o kadar da akillica bir durum değil. güvenlik açisindan sakıncalari var ayrıca http ağinda timeoutlar sebebi ile uzun suren DBA işlemlerinde problemler oluşabilir. bu problerim üstesinden gelmek için ve başinizin ağrimamasi için sql*plus ise konsoldan bağlanmanizi tavsiye ediyor ben dahil herkez.

isqlplus da connect sys/****** as sysdba komutunu yazdiğinizda size

SP2-0927: CONNECT AS SYSDBA or AS SYSOPER not allowed through iSQL*Plus URL

mesajini verecektir. Bunu aşmak için birkaç ayar yapmanız yeterli.

kısa kısa sql*plus

1- iSQL*PLUS log ayarlarları

$ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/isqlplus/isqlplus/WEB-INF/classes

dizinin içerisinde log4j.rootLogger dosyası bulunuyor. Bu dosyada isql*plus logları ile ilgili ayarlar var. Eğer bu dosyada daha önce bir değişiklik yapmadıysanız fatal error hatalarını verecektir. Orada hangi logların tutulacağı belirtiliyor. İstediğinizi aktif yapabilirsiniz.

2- System değişkenlerini kurtarma.

bu işlem için kullanılan komut STORE komutudur. SROTE komutu ile command da ve GUI ortamındaki değişkenleri saklayabiliriz.Eğer herhangibi bir sistem değişkenini değiştirdiyse ve bunu geri almak istiyorsak bu komutu kullanmaliyiz.

STORE SET dosya_adi

komutunu girdiğimiz zaman o anki değişkenleri kaydediyoruz. daha sonra sistemde isteğimiz değişikliği yapabiliriz. dosya_adi.sql şeklinde tutuluyor. Bir süre sonra eski ayarlara dönmek istersek

START dosya_adi

@doya_adi @@dosya_adi //bu komutlarla da çalişiyor.

kullanarak eski halie geri getiriz.

3 - Giriş portunun ayarlanmasi.

Bazen öyle durumlar olabilirki sistemde sizin kullandiğiniz portu bir başka program kullanılayor olabilir. port çakışmalarını önlemek için iqql*plus port numarasi değiştirebilirsiniz. Bu değişikliğin aktif olmasi için isql*plus açip kapatmaniz gerekebir. (ben açip kapatmadan da aktif oldugunu gördum ama belki uzaktan erişimlerde bole birşeye gerek duyuluyor olabilir.)

$ORACLE_HOME/oc4j/j2ee/isqlplus/config

bu dizinde http-web-site.xml dosyası bulunuyor bunun içerisine baktiğinizda zaten göreceksiniz oradan değiştirip uyguluyorsunuz. unutmayiniz port numarası özgun olmalıdır.

4- iSQL*PLUS oturum süresi

eğer bir sayfada belirili bir süre hiçbirşey yapmazsaniz sizden yeniden girmenizi isteyecektir. Bu süreyi belirlemek sizin elinizde. aşağidaki dizinden web.xml dosyasında

$ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/isqlplus/isqlplus/WEB-INF


15

satirlarda 15 değeri varsayılandır. buraya 1-1440 arasında bir değer girebilirsiniz.