Oracle SQL CheatSheet

August 27, 2008 – 10:15 pm

1. What is SDO_GEOMETRY?


SDO_GEOMETRY{
    SDO_GTYPE, - GeometryType: D00T
                    D: Dimension (2: 2d, 3: 3d, 4:4d)
                    T:GeometryType(
                        0 - unknown
                        1 - point
                        2 - line
                        3 - polygon
                        4 - collection
                        5 - multipoint
                        6 - multiline
                        7 - multipolygon
                    )
    SDO_SRID,
    SDO_POINT, - NULL for line, polygon, etc.
    SDO_ELEM_INFO,
    SDO_ORDINATES
}
 

2. How to load data in bulk?
Use SQLLDR username/password CONTROL=filename DATA=filename (see blog post)

3. ALTER TABLE
ALTER TABLE geo_entities MODIFY meta_name varchar(255)

4. AUTO INCREMENT COLUMN
CREATE SEQUENCE seq_geo_entities INCREMENT BY 1 START WITH 1;

5. Concatenating Strings
SELECT concat(’hello’, ‘rupert’) FROM DUAL;
SELECT ‘hello’ || ‘rupert’ FROM DUAL;

Using SDO_WITHIN_GEOM

August 27, 2008 – 9:00 pm

Experiment 1: Two POIs


SELECT
  p1.poi_id,
  p1.en_name,
  p1.py_fullpoiadd,
  p1.py_rdname,
  p2.poi_id,
  p2.en_name,
  p2.py_fullpoiadd,
  p2.py_rdname,
  SDO_GEOM.SDO_DISTANCE(p1.geom, p2.geom, 0.5) AS dist
FROM poi_test p1, poi_test p2
WHERE
    Upper(p1.en_name) LIKE '%PARKSON%'
AND Upper(p2.en_name) LIKE '%KFC%'
AND SDO_WITHIN_DISTANCE(p1.geom, p2.geom, 'DISTANCE=500 UNIT=METER' )='TRUE'
ORDER BY dist
 

Experiment 2: Road + Two POIs


SELECT
  p1.poi_id,
  p1.en_name,
  p1.py_fullpoiadd,
  p1.py_rdname,
  p2.poi_id,
  p2.en_name,
  p2.py_fullpoiadd,
  p2.py_rdname,
  SDO_GEOM.SDO_DISTANCE(p1.geom, p2.geom, 0.5) AS dist
FROM poi_app p1, poi_app p2, geo_entities g
WHERE
    Upper(p1.en_name) LIKE '%BAR BLU%'
AND Upper(p2.en_name) LIKE '%KOKOMO%'
AND     Upper(g.meta_name) LIKE '%SANLITUN%'
AND SDO_WITHIN_DISTANCE(p1.geom, p2.geom, 'DISTANCE=500 UNIT=METER' )='TRUE'
AND SDO_WITHIN_DISTANCE(p1.geom, g.the_geom, 'DISTANCE=500 UNIT=METER' )='TRUE'
AND SDO_WITHIN_DISTANCE(p2.geom, g.the_geom, 'DISTANCE=500 UNIT=METER' )='TRUE'
 

Notes:
1. Significant improvement when Sorting is removed.

Oracle Text Notes

August 27, 2008 – 12:33 am

Just a couple of notes from studying Oracle Text…

1. What is the default index?
Its CONTEXT. The text column can be of type CLOB, BLOB, BFILE, VARCHAR2, or CHAR.

CREATE INDEX idx_ft_meta_en_name ON poi_app(ft_meta_en_name) INDEXTYPE IS CTXSYS.CONTEXT;

2. When you perform inserts or updates on the base table, you must explicitly synchronize the index with CTX_DDL.SYNC_INDEX.

SQL> EXEC CTX_DDL.SYNC_INDEX(’idx_docs’, ‘2M’);

3. CONTAINS Phrase Queries

If multiple words are contained in a query expression, separated only by blank spaces (no operators), the string of words is considered a phrase and Oracle Text searches for the entire string during a query.

4. Logical Operators
Picture 1.png

5. Some sample SQL queries:


-- Simple Query
SELECT SCORE(1) AS myscore, en_name, en_visname, py_name FROM poi_app WHERE CONTAINS(ft_meta_en_name, 'grammy center', 1) > 0 ORDER BY myscore DESC;

SELECT SCORE(1) AS myscore, en_name, en_visname, py_name FROM poi_app WHERE CONTAINS(ft_meta_en_name, 'cybersoft', 1) > 0;

-- Query Rewrite
SELECT en_name, en_visname, py_name
FROM poi_app
WHERE CONTAINS (ft_meta_en_name,
'<query>
<textquery lang="ENGLISH" grammar="CONTEXT"> international hotel boya
<progression>
<seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq>
</progression>
</textquery>
<score datatype="INTEGER" algorithm="COUNT"/>
</query>'
)>0;

&#8211; Query 'About'
SELECT en_name, en_visname, py_name, score(1)
FROM poi_app
WHERE CONTAINS(ft_meta_en_name, 'about(italian restaurants)', 1) > 0
ORDER BY SCORE(1) DESC;

&#8211; Query logical
SELECT en_name, en_visname, py_name, score(1)
FROM poi_app
WHERE CONTAINS(ft_meta_en_name, 'beijing, international, hotel', 1) > 0
ORDER BY SCORE(1) DESC;
 

Migrating Postgres / Postgis Tables to Oracle Spatial

August 19, 2008 – 3:26 pm


Step 1: Installing and configuring

1. On Windows, make sure that Windows > Settings > Control Panel > Regional Settings
- Chinese (PRC)

Picture 1.png

2. Install Oracle10g
- make sure you have spatial installed


SQL> SELECT COMP_NAME, STATUS
FROM DBA_REGISTRY
WHERE COMP_NAME = 'Spatial';
 

3. Create a multilingual database using dbca. Make sure setting is set to UTF8. I installed the sample schema for learning purposes. Read this previous post for more information.

4. We can add a user for our spatial database or just enable scott/tiger from the Enterprise Manager.

Picture 15.png

On Administration > Users > “Search for SCOTT” > Hit EDIT > UNLOCK the status.

Picture 16.png


Step 2: Get Oracle Client Tools


1. On the same WindowsXPSP3 machine that I installed Oracle. There is already SQL*Plus. However I always go for the native which is CLI based. So on a command prompt, sqlplus still works. Also note that I can toggle to my previous commands using “Arrow Up”. If we have the Oracle Database installed on a different machine, we need to download the ff:

* Oracle SQL Developer (Java GUI-Based)
http://www.oracle.com/technology/software/products/sql/index.html

* Oracle 10g Client for Windows (10201_client_win32 1.zip 453MB)

* Oracle 10g Client for MacOS (Oracle_10204Client_MAC_X86.zip 189MB) - rarely used.

* Oracle Instant Client for MacOS (instantclient-basic-macosx-10.2.0.4.0.zip 32MB) - need to try this.


Step 3: Creating the Table


1. POI Table


CREATE TABLE poi
(
  poi_id number(10),
  cn_name varchar2(255),
  py_name varchar2(255),
  en_name varchar2(255),
  en_visname varchar2(255),
  cn_fullpoiadd varchar2(255),
  en_fullpoiadd varchar2(255),
  py_fullpoiadd varchar2(255),
  cn_rdname varchar2(255),
  py_rdname varchar2(255),
  cn_address_no varchar2(255),
  py_address_no varchar2(255),
  cn_address_other varchar2(255),
  py_address_other varchar2(255),
  postal varchar2(20),
  tel_no varchar2(255),
  fax_no varchar2(255),
  email varchar2(255),
  web_url varchar2(255),
  operating_hours  varchar2(4000),
  cards_accepted  varchar2(4000),
  cust_capacity  varchar2(4000),
  park_space  varchar2(4000),
  longitude number(20,8),
  latitude number(20,8),
  CONSTRAINT "poi_pkey" PRIMARY KEY (poi_id)
);
 


Step 4: Exporting to TextFile with “|”


Export the table into a textfile. Run the SQL statement below on Navicat. Afterwards, run the “Export Wizard” and specify “|” as the delimiter.


SELECT
  poi_id,
  cn_name,
  py_name,
  en_name,
  en_visname,
  cn_fullpoiadd,
  en_fullpoiadd,
  py_fullpoiadd,
  cn_rdname,
  py_rdname,
  cn_address_no,
  py_address_no,
  cn_address_other,
  py_address_other,
  postal,
  tel_no,
  fax_no,
  email,
  web_url,
  operating_hours,
  cards_accepted,
  cust_capacity,
  park_space,
  longitude,
  latitude
FROM poi
 

Find out how many lines were exported using “wc -l file-name”. If there are more lines than actual records then most likely there are ‘\n’ (newlines / carriage returns) on the exported file.


Step 5: Use SQLLOADER to bulkload the data

SQLLDR scott/tiger CONTROL=poi_full.ctl DATA=data_navicat_cn_all2.dat

Since we have point data in longitude, latitude columns. It is very easy to populate the SDO_GEOMETRY with these columns.


Step 6: Creating Point Geometries from Long/Lat Columns


CREATE TABLE poi_app AS SELECT * FROM poi WHERE latitude > 0 AND longitude > 0;

ALTER TABLE poi_app ADD the_geom SDO_GEOMETRY;

UPDATE poi_app
SET the_geom = SDO_GEOMETRY( 2001, NULL, SDO_POINT_TYPE(longitude, latitude, NULL), NULL, NULL);

INSERT INTO USER_SDO_GEOM_METADATA VALUES
(
    'poi_app', -- TABLE_NAME
    'the_geom', -- COLUMN_NAME
    SDO_DIM_ARRAY -- DIMINFO attribute for storing dimension bounds, tolerance
    (
        SDO_DIM_ELEMENT
        (
            'LONGITUDE', -- DIMENSION NAME for first dimension
            -180, -- SDO_LB for the dimension
            180, -- SDO_UB for the dimension
            0.5 -- Tolerance of 0.5 meters
        ),
        SDO_DIM_ELEMENT
        (
            'LATITUDE', -- DIMENSION NAME for second dimension
            -90, -- SDO_LB for the dimension
            90, -- SDO_UB for the dimension
            0.5 -- Tolerance of 0.5 meters
        )
    ),
    4326 -- SRID value for specifying a geodetic coordinate system
);

CREATE INDEX idx_poi_app_the_geom ON poi_app(the_geom) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
 

Once the index is created, Oracle creates a SEQUENCE(MDRS_C796$) and a TABLE(MDRT_C796$). Please do not delete this table. I accidentally deleted this table and I have to recreate the indexes–well it was not that easy. I have to DROP INDEX, insert it into USER_SDO_GEOM_METADATA, then CREATE INDEX.

Note that it is important to include the geometry to be indexed in the USER_SDO_GEOM_METADATA table. This should happen before creating the index or receive an error like…

Picture 2.png


Step 7: Creating Geometries from ESRI Shapefiles


* PGSQL2SHP - Use this to convert from a postgres table to an ESRI Shapefile. Note that if you have mixed geometries in a single column, then you need output different shapefiles for each geometry. For example, I have a “geo_entities” table which contains polygons, multipolygons, and multilinestrings. I was able to come up with three (3) different shapefiles for each geometry. Then afterwards load the individual shapefiles using SDO2SHP below.


pgsql2shp -f geo_entities_2006 -h 127.0.0.1 -u lbs -P ******* -g the_geom beijing_app "SELECT gid,cn_name,py_name,en_name,entity_type,geom_type,meta_name,cn_district,the_geom FROM geo_entities WHERE GeometryType(the_geom) = 'MULTILINESTRING'"
 

* Ensure that you download SDO2SHP


shp2sdo shp\geo_entities_2007 geo_entities_2007 -g the_geom -x (-180,180) -y (-90,90) -s 4326
-t 0.5 -v
 

The output of SHP2SDO are three (3) files:

a. CTL - control file containing “LOAD DATA…”
b. SQL - contains “CREATE TABLE…”
c. DAT - Data with “#”

Oracle: Creating a MultiLingual Database

August 19, 2008 – 2:47 pm

Notes on to create a multilingual database in UTF8 in Oracle10g.

1. Run the Oracle Database Configuration Assistant (DBCA)

Picture 2.png

2. Choose Create Database

Picture 3.png

3. Choose “General Purpose”.

4. Then specify the GLOBAL DATABASE NAME or ORACLE SID (orcl4)

Picture 5.png

5. Click Next on Management Options.

6. On “Database Credentials”, use the same passwords so we would not forget them for now…

Picture 7.png

7. On “Storage Options”. Default options is FILE STORAGE. Next.

8. On “Database File Locations”, hit Next as well.

9. On “Recover Options”, same goes here.. Next.

10. On “Database Content”, install the sample schemas for practice.
Picture 11.png

11. On “Initialization Parameters”, click on the “Character Sets” tab. Note that we chose the 2nd option which is “Use Unicode” (ALT32UTF8) in order to support chinese. On the National Character Set, please choose “UTF8″ (the 2nd option in the drop-down list”) also.

Picture 12.png

12. Hit Next until we create the database.

13. To check you should have the Oracle Services installed in your Services.

Picture 14.png

Using GDALWARP to reproject raster that will fit with Google Satellite

July 29, 2008 – 8:48 pm

Just a couple of notes to onself using gdal: Use gdalwarp to reproject your GeoTIFF files! I wanted to use my own satellite images acquired from GeoEye, however, on some areas I wanted to use google sat images as well since I don’t have the coverage. In order to do so, I need to reproject the sat images to 900913. Note you need to specify this in your epsg file in my previous post.


rupert:beijing_900913_satellite rupert$ gdalinfo Mosaic_RGB.tif
Driver: GTiff/GeoTIFF
Files: Mosaic_RGB.tif
Size is 4248, 4553
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.2572235630016,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (116.291476140000000,40.025198500000002)
Pixel Size = (0.000046860000000,-0.000035970000000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_XRESOLUTION=100
  TIFFTAG_YRESOLUTION=100
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 116.2914761,  40.0251985) (116d17'29.31&#8243;E, 40d 1'30.71&#8243;N)
Lower Left  ( 116.2914761,  39.8614271) (116d17'29.31&#8243;E, 39d51'41.14&#8243;N)
Upper Right ( 116.4905374,  40.0251985) (116d29'25.93&#8243;E, 40d 1'30.71&#8243;N)
Lower Right ( 116.4905374,  39.8614271) (116d29'25.93&#8243;E, 39d51'41.14&#8243;N)
Center      ( 116.3910068,  39.9433128) (116d23'27.62&#8243;E, 39d56'35.93&#8243;N)
Band 1 Block=4248&#215;1 Type=Byte, ColorInterp=Red
Band 2 Block=4248&#215;1 Type=Byte, ColorInterp=Green
Band 3 Block=4248&#215;1 Type=Byte, ColorInterp=Blue
 

rupert:beijing_900913_satellite rupert$ gdalwarp -s_srs epsg:4326 -t_srs epsg:900913 Mosaic_RGB.tif sat_4m_rgb.tif
Creating output file that is 4245P x 4556L.
Processing input file Mosaic_RGB.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.
 

rupert:beijing_900913_satellite rupert$ gdalinfo sat_4m_rgb.tif
Driver: GTiff/GeoTIFF
Files: sat_4m_rgb.tif
Size is 4245, 4556
Coordinate System is:
PROJCS["Google Maps Global Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.2572235630016,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (12945507.907502911984921,4869604.732793668285012)
Pixel Size = (5.219801430503303,-5.219801430503303)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (12945507.908, 4869604.733) (116d17'29.31&#8243;E, 40d12'53.10&#8243;N)
Lower Left  (12945507.908, 4845823.317) (116d17'29.31&#8243;E, 40d 3'2.78&#8243;N)
Upper Right (12967665.965, 4869604.733) (116d29'25.89&#8243;E, 40d12'53.10&#8243;N)
Lower Right (12967665.965, 4845823.317) (116d29'25.89&#8243;E, 40d 3'2.78&#8243;N)
Center      (12956586.936, 4857714.025) (116d23'27.60&#8243;E, 40d 7'58.12&#8243;N)
Band 1 Block=4245&#215;1 Type=Byte, ColorInterp=Red
Band 2 Block=4245&#215;1 Type=Byte, ColorInterp=Green
Band 3 Block=4245&#215;1 Type=Byte, ColorInterp=Blue
 

MacOSX Utilities: iTerm + MarsEdit

July 29, 2008 – 1:25 am

Just a quick note before I go home tonight…

1. Replace your current terminal with iTerm.

2. MarsEdit rocks! Ive been posting lazy and all but with this blog client at hand.. blog posting is easier. Way way better compared to ecto!! (IMHO).

Installing Chinese Font for Mapserver

July 28, 2008 – 11:02 pm

We wanted to use a different font for mapserver which is Microsoft Yahei instead of zysong. Apparently, mapserver have some issues with path problems or with the ttf having more than one word as a font name.

Thanks to Martin Hosken’s perl modules for fonts, we were able to rename the Microsoft Yahei TTF to msyh.ttf.

1. Download: (a) Font-TTF-0.45 (b) Font-TTF-Scripts-0.11.1

2. Unzip


#perl Makefile.pl
#make
#make install
 

3. ttfname


rupert:Desktop rupert$ ttfname
Usage:
ttfname [-f "full_name"] -n "name" [-t num] [-q] infile.ttf outfile.ttf
Renames the TTF with the given name and outputs the newly named font to out.ttf.
Options:
      -f "name"   specifies new full name (optional) as opposed to the
                  default calculated form.
      -l lang     language number to use (default all langs)
                  if specified name entries will be added for all platforms and
                      encodings covered by the cmap if not already there
      -n "name"   specifies new font family name (not optional)
      -q          disable signon message
      -s filename overrides -n and gets string from file. Useful for -t
      -t num      overrides the normal naming areas to change another
                  string -f becomes inactive.
#ttfname -f "Microsoft YaHei" -n "msyh" Microsoft\ YaHei.ttf msyh.ttf
 

Picture 1.png

Postgres Clients Update: Navicat and EMS

July 28, 2008 – 12:37 am

Picture 4.png

Navicat already produced some lite (free) versions for Postgres both for Windows and Mac. Browse over the feature matrix to find out which version works for you. Note that all versions allow you to edit the record which I can’t do in pgadmin3.

Picture 3.png

A quick look at EMS on Windows (VMWare) is also a note worthy client. Though the MDI interface is a bit complex, one good feature is to able to see your spatial geometry as text and the corresponding SRID immediately…

Picture 1.png

Picture 2.png

Installing Oracle x64 on CentOS5

July 26, 2008 – 12:36 pm

FOR EDITING.. This is just a couple of notes from my Oracle testing a few weeks back that I forgot to post..

A. Installing

1. Check for rpm packages:


rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21 elfutils-libelf libaio-devel libgcc
 

2. install the necessary rpm packages:


rpm -ivh compat-db-4.2.52-5.1.x86_64.rpm
rpm -ivh libgnome-2.16.0-6.el5.x86_64.rpm
rpm -ivh sysstat-7.0.0-3.el5.x86_64.rpm
rpm -ivh libaio-devel-0.3.106-3.2.x86_64.rpm
rpm -ivh lm_sensors-2.10.0-3.1.x86_64.rpm
rpm -ivh beecrypt-devel-4.1.2-10.1.1.x86_64.rpm elfutils-devel-0.125-3.el5.x86_64.rpm net-snmp-devel-5.3.1-19.el5.x86_64.rpm elfutils-devel-static-0.125-3.el5.x86_64.rpm net-snmp-5.3.1-19.el5.x86_64.rpm net-snmp-libs-5.3.1-19.el5.x86_64.rpm
 

3. edit /root/.bash_profile

4. Create oracle Account


groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle
id oracle
 

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)

5. Run modify_kernel.sh


cat >> /etc/sysctl.conf << EOF
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1025 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
EOF
 

6. vim /etc/sysctl.conf and comment kernel.shmall and kernel.shmmax because if
you don’t then we will have double results

7. /sbin/sysctl -p

8. Create Directories:


mkdir -p /u01
mkdir -p /opt/oracle
mkdir -p /opt/oracle/product
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /opt/oracle
chmod -R 755 /u01
chmod -R 755 /opt/oracle
chmod -R 755 /opt/oracle/product
 

9. Run sh -v modify_shelllimits.sh

10. Add the ff lines in /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so

11. cp -rf /home/installers/linux.x64_11gR1_database.zip /opt/oracle

12. chown oracle:oinstall /opt/oracle/linux.x64_11gR1_database.zip

13. Clost all terminals and logout as root from desktop.

14. Login as oracle

15. Follow tutorial until installing oracle
Installing Oracle 11g on CentOS under VMWare on a Macbook.doc

16. Run the 2 scripts after the dialog:

[root@cs5ora11g db1]# sh root.sh
Running Oracle 11g root.sh script…

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/11.1.0/db1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin …
Copying oraenv to /usr/local/bin …
Copying coraenv to /usr/local/bin …

Creating /etc/oratab file…
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

17. Open your firewall to 1158

18. Go to https://192.168.1.155:1158/em

- Login as SYSMAN:[password] (nickname+wife)

19. Install Oracle Instant Client for your distro [MacOS]
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

a. Add exports to runsqlplus.sh
b. copy tnsnames.ora from centos to mac
c. add in firewall: 1521
d. sh runsqlplus.sh

20. do sqlplus
Enter user-name: SYSMAN@cybersof
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>

You are now connected successfully.

21. Check for oracle processes: ps -ef | grep ora


SQLPLUS DBINSTANCE:
oraclecybersof (LOCAL=NO)

ORACLE LISTENER:
/opt/oracle/product/11.1.0/db1/bin/tnslsnr LISTENER -inherit

ORACLE ENTERPRISE MANAGER:
oracle   14487     1  0 15:37 ?        00:00:00
/opt/oracle/product/11.1.0/db1/perl/bin/perl
/opt/oracle/product/11.1.0/db1/bin/emwd.pl dbconsole
/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc/sysman/log/emdb.nohup
oracle   14511 14487  2 15:37 ?        00:00:36
/opt/oracle/product/11.1.0/db1/jdk/bin/java -server -Xmx512M
-XX:MaxPermSize=1024M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40
-DORACLE_HOME=/opt/oracle/product/11.1.0/db1
-Doracle.home=/opt/oracle/product/11.1.0/db1/oc4j
-Doracle.oc4j.localhome=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc/sysman
-DEMSTATE=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc
-Doracle.j2ee.dont.use.memory.archive=true
-Djava.protocol.handler.pkgs=HTTPClient
-Doracle.security.jazn.config=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/jazn.xml
-Djava.security.policy=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/java2.policy
-Djavax.net.ssl.KeyStore=/opt/oracle/product/11.1.0/db1/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/home/config/jazn.security.props
-DEMDROOT=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc
-Dsysman.md5password=true -Drepapi.oracle.home=/opt/oracle/product/11.1.0/db1
-Ddisable.checkForUpdate=true
-Doracle.sysman.ccr.ocmSDK.websvc.keystore=/opt/oracle/product/11.1.0/db1/jlib/emocmclnt.ks
-Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar
/opt/oracle/product/11.1.0/db1/oc4j/j2ee/home/oc4j.jar -config
/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/server.xml
 

22. Set Oracle Environment


# su - oracle
# vim ~/.bash_profile
ORACLE_BASE=/opt/oracle/product
ORACLE_SID=cybersof
ORACLE_HOME=/opt/oracle/product/11.1.0/db1
export ORACLE_BASE ORACLE_SID ORACLE_HOME

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
 

23. Shutdown and Startup of Oracle


$ . oraenv
<enter your SID>

$ sqlplus "/ as sysdba"
SQL> startup
SQL> exit

$ lsnrctl
LSNRCTL> start
LSNRCTL> exit

$ cd $ORACLE_HOME/bin
./emctl start dbconsole
 

B. Creating Users

Login to https://192.168.1.155:1158/em
username:sysman
password: [nickname+wifey]
connect as “sysdba”

1. Creating admin user:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28301/admqs_administer_users.htm#CHDBDBGI

em > Setup > Administrators > Create

2. Create appdev user:
em > Server > Roles
http://download.oracle.com/docs/cd/B28359_01/server.111/b28301/admqs_administer_users.htm

http://www.databasedesign-resource.com/users-in-oracle.html

Picture 1.png