Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

create_commands

The document outlines a series of SQL commands to create and manipulate a table named 'emp1'. It includes creating the table, inserting records, updating salaries, rolling back transactions, and deleting records. The final state shows that the table is empty after deleting all entries.

Uploaded by

nooremaan414
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

create_commands

The document outlines a series of SQL commands to create and manipulate a table named 'emp1'. It includes creating the table, inserting records, updating salaries, rolling back transactions, and deleting records. The final state shows that the table is empty after deleting all entries.

Uploaded by

nooremaan414
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL> clear scr;

SQL> create table emp(


2 id number(10),
3 name varchar2(30),
4 salary number(10)
5 ,
6 date Date,
7 constraint pkey primary key(id)
8 );
SP2-0640: Not connected
SQL> ed
Wrote file afiedt.buf

1 create table emp(


2 id number(10),
3 name varchar2(30),
4 salary number(10)
5 ,
6 date Date,
7 constraint pkey primary key(id)
8* )
SQL> conn hr;
Connected.
SQL> ed
Wrote file afiedt.buf

1 create table emp(


2 id number(10),
3 name varchar2(30),
4 salary number(10)
5 ,
6 date Date,
7 constraint pkey primary key(id)
8* )
SQL> /
date Date,
*
ERROR at line 6:
ORA-00904: : invalid identifier

SQL> ed
Wrote file afiedt.buf

1 create table emp(


2 id number(10),
3 name varchar2(30),
4 salary number(10),
5 constraint pkey primary key(id)
6* )
SQL> /
create table emp(
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> ed
Wrote file afiedt.buf

1 create table emp1(


2 id number(10),
3 name varchar2(30),
4 salary number(10),
5 constraint pkey primary key(id)
6* )
SQL> /

Table created.

SQL> clear scr;

SQL> desc emp1;


Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER(10)
NAME VARCHAR2(30)
SALARY NUMBER(10)

SQL> insert into emp1 values(1,'ali',10000);

1 row created.

SQL> select * from emp1;

ID NAME SALARY
---------- ------------------------------ ----------
1 ali 10000

SQL> update emp1 set salary=15000 where id=1;

1 row updated.

SQL> select * from emp1;

ID NAME SALARY
---------- ------------------------------ ----------
1 ali 15000

SQL> insert into emp1 values(2,'khan',10000);

1 row created.

SQL> insert into emp1 values(3,'umar',10000);

1 row created.

SQL> update emp1 set salary=10000;

3 rows updated.

SQL> rollback;

Rollback complete.

SQL> select * from emp1;


no rows selected

SQL> rollback;

Rollback complete.

SQL> select * from emp;

no rows selected

SQL> insert into emp1 values(1,'umar',10000);

1 row created.

SQL> insert into emp1 values(2,'umar',10000);

1 row created.

SQL> update emp1 set salary=15000;

2 rows updated.

SQL> select * from emp1;

ID NAME SALARY
---------- ------------------------------ ----------
1 umar 15000
2 umar 15000

SQL> delete from emp1 where id=2;

1 row deleted.

SQL> insert into emp1 values(2,'umar',10000);

1 row created.

SQL> delete from emp1;

2 rows deleted.

SQL> clear scr;

SQL> spool off

You might also like