Some quick commands for oracle:
1. Some useful commands
To start a session as sysdba: sqlplus sys@tnsname as sysdba; To start a sysdba session under Windows (9iAS): sqlplus "/as sysdba" To list all tables in current schema: SELECT table_name FROM user_tables; or, all tables current user has access to: SELECT table_name FROM all_tables; To list all schemas: SELECT username FROM all_users ORDER BY username; To turn pause on: SET PAUSE ON; To list top n rows of a table in order: SELECT * FROM (SELECT * FROM t ORDER BY c) WHERE ROWNUM <= n; Show current database: SELECT * FROM global_name; Use database: CONNECT schema/password@tnsname; Show who I am: SHOW USER; Describe table: DESC tablename; Set display rows: SET PAGESIZE 66; Read field constraints: SELECT constraint_name,search_condition FROM user_constraints WHERE table_name='tablename'; Copy table from foreign host to here: COPY FROM user@tnsname CREATE tablename USING SELECT * FROM tablename; Start SQLPLUS without login: SQLPLUS /NOLOG Change a user’s password: ALTER USER user IDENTIFIED BY password; Unlock an account ALTER USER user ACCOUNT UNLOCK;
2. Autonumbers
Oracle has no autonumbers like SQL Server, Access, or MySQL. One way to do autonumbers is by using a combination of a sequence and a trigger, as in the following example:
CREATE SEQUENCE sequence-name; CREATE OR REPLACE TRIGGER trigger-name BEFORE INSERT ON table-name FOR EACH ROW WHEN (NEW.field-name IS NULL OR NEW.field-name = '<new>') BEGIN SELECT 'PR-' || sequence-name.NEXTVAL INTO :NEW.field-name FROM DUAL; END; /
3. JDeveloper
To create a new JDeveloper application that will contain “raw” JSP code, follow these steps:
- Create New Workspace
- Create New Empty Project
- Create New Class
- Create New JSP
You may find that you need to specify additional libraries with which to link your project. To do so, select Project Settings in the menu and insert additional CLASSPATHs, e.g., I had to add S:\INSTALLS\ORACLE\JDeveloper-9i2\jdbc\lib\classes12.jar.
To create a new database application using Oracle’s classes, follow these steps:
- Create New Workspace
- Create New Project with Business Components
- Default package: mypackage1
- Create New BC4J JSP Browse & Edit Form
4. Deploying an application
Before any of these steps, you must create a deployment profile in JDeveloper, and deploy the project to an EAR file. Then:
- Connect to the application server’s Enterprise Manager (TCP port 1810)
- Select the server
- Click OC4J_Home
- Click Deploy EAR File
- Specify file location, application name
- Specify base URL
- Specify JAZN LDAP authentication for SSO
Your application will then appear under the URL http://your.oracle9iAS.server:7777/base-URL. (The port number may be something other than 7777 depending on your AS setup.) You may need to restart OC4J_Home if, after deployment, the application misbehaves (Java compiler errors, out of memory errors, etc.)
If the application fails to run due to missing libraries, check your deployment profile. Make sure all libraries are included. If all else fails, then instead of using the dependency analyzer, choose to include all necessary libraries in their entirety.
5. Some default passwords
Sphere: Related Content
Name Password sys change_on_install system manager orcladmin welcome
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

Core Networks homepage
Oracle University