You are on page 1of 7

Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\user>sqlplus hr/hr@ORCL SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 31 17:02:01 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: hr Enter password: Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> CREATE USER MySystem IDENTIFIED BY systemadmin; User created. SQL> GRANT CONNECT, RESOURCE, DBA TO MySystem; Grant succeeded. SQL> quit Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Produ ction C:\Users\user>sqlplus MySystem/systemadmin@ORCL SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 31 17:06:19 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: MySystem Enter password: Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> CREATE TABLE MyORCL_tbl{

2 id NUMBER, 3 name VARCHAR2, 4 dob DATE 5 }; CREATE TABLE MyORCL_tbl{ * ERROR at line 1: ORA-00911: invalid character

SQL> CREATE TABLE MyORCL_tbl( 2 id NUMBER(3), 3 name VARCHAR2(100), 4 dob DATE 5 ); Table created. SQL> INSERT INTO MyORCL_tbl (id, name, dob) values(1, 'Matthew John F. Sino Cruz ', '02-FEB-17'); 1 row created. SQL> SELECT * from MyORCL_tbl; ID ---------NAME -------------------------------------------------------------------------------DOB --------1 Matthew John F. Sino Cruz 02-FEB-17

SQL> quit Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Produ ction C:\Users\user>sqlplus MySYSTEM/systemadmin SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 31 17:14:26 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> select * from MyORCL_tbl; ID ---------NAME -------------------------------------------------------------------------------DOB --------1 Matthew John F. Sino Cruz 02-FEB-17

SQL> //next line Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\user>sqlplus MySYSTEM/systemadmin@ORCL SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 31 17:35:25 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: MySYSTEM AS SYSDBA Enter password: Connected to an idle instance. SQL> startup; ORACLE instance started. Total System Global Area 285212672 bytes Fixed Size 1287016 bytes Variable Size 104860824 bytes Database Buffers 176160768 bytes Redo Buffers 2904064 bytes Database mounted. Database opened.

SQL> quit Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Produ ction C:\Users\user>sqlplus MySYSTEM/systemadmin SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 31 17:48:35 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> ALTER TABLE MyORCL_tbl ADD CONSTRAINT contraint_name PRIMARY KEY(id); Table altered. SQL> describe MyORCL_tbl; Name Null? Type ----------------------------------------- -------- ---------------------------ID NAME DOB NOT NULL NUMBER(3) VARCHAR2(100) DATE

SQL> CREATE TABLE MyORCL_educ( 2 educ_id NUMBER(3), 3 id NUMBER(3), 4 course varchar2(50), 5 grad date 6 ); Table created. SQL> ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name FOREIGN KEY(id) REFE RENCES MyORCL_tbl(id); Table altered. SQL> describe MyORCL_educ; Name Null? Type ----------------------------------------- -------- ---------------------------EDUC_ID ID COURSE GRAD NUMBER(3) NUMBER(3) VARCHAR2(50) DATE

SQL> ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name PRIMARY KEY (educ_id ); ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name PRIMARY KEY (educ_id) * ERROR at line 1: ORA-02264: name already used by an existing constraint

SQL> ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name PRIMARY KEY (educ_id ); ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name PRIMARY KEY (educ_id) * ERROR at line 1: ORA-02264: name already used by an existing constraint

SQL> ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name UNIQUE (educ_id); ALTER TABLE MyORCL_educ ADD CONSTRAINT constraint_name UNIQUE (educ_id) * ERROR at line 1: ORA-02264: name already used by an existing constraint

SQL> insert into MyORCL_educ(educ_id, id, course, grad) values(1, 2, 'BSICT', '2 0-MAR-10'); insert into MyORCL_educ(educ_id, id, course, grad) values(1, 2, 'BSICT', '20-MAR -10') * ERROR at line 1: ORA-02291: integrity constraint (MYSYSTEM.CONSTRAINT_NAME) violated - parent key not found

SQL> insert into MyORCL_educ(educ_id, id, course, grad) values(1, 1, 'BSICT', '2 0-MAR-10'); 1 row created. SQL> insert into MyORCL_tbl(id, name, dob) values ('', 'Cherry Rose Espiritu', ' 17-OCT-95'); insert into MyORCL_tbl(id, name, dob) values ('', 'Cherry Rose Espiritu', '17-OC T-95') * ERROR at line 1: ORA-01400: cannot insert NULL into ("MYSYSTEM"."MYORCL_TBL"."ID")

SQL> insert into MyORCL_tbl(id, name, dob) values (2, 'Cherry Rose Espiritu', '1 7-OCT-95'); 1 row created. SQL> insert into MyORCL_tbl(id, name, dob) values (2, 'Deanamy C. Tablada', '21DEC-95'); insert into MyORCL_tbl(id, name, dob) values (2, 'Deanamy C. Tablada', '21-DEC-9 5') * ERROR at line 1: ORA-00001: unique constraint (MYSYSTEM.CONTRAINT_NAME) violated

SQL> insert into MyORCL_tbl(id, name, dob) values (3, 'Deanamy C. Tablada', '21DEC-95'); 1 row created. SQL> select * from MyORCL_tbl;p 2 ; select * from MyORCL_tbl;p * ERROR at line 1: ORA-00911: invalid character

SQL> select * from MyORCL_tbl; ID ---------NAME -------------------------------------------------------------------------------DOB --------1 Matthew John F. Sino Cruz 02-FEB-17 2 Cherry Rose Espiritu 17-OCT-95 ID ---------NAME --------------------------------------------------------------------------------

DOB --------3 Deanamy C. Tablada 21-DEC-95

SQL>

You might also like