Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

09 02 23 (FN)

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 28

create table

table_name(attribute1
datatype1, attribute2
datatype2)

insert into table_name


values(value1,value2);
SQL*Plus: Release
11.2.0.2.0 Production on
Thu Feb 9 09:10:20 2023

Copyright (c) 1982, 2014,


Oracle. All rights reserved.

SQL> connect
Enter user-name: sys as
sysdba
Enter password:
Connected.
SQL> create table
stud1(name char,age int);

Table created.

SQL> insert into stud1


values('aaa',18);
insert into stud1
values('aaa',18)
*
ERROR at line 1:
ORA-12899: value too large
for column
"SYS"."STUD1"."NAME"
(actual: 3, maximum:
1)

SQL> insert into stud1


values('a',18);
1 row created.

SQL> insert into stud1


values('b',19);

1 row created.

SQL> insert into stud1


values('c',20);
1 row created.

SQL> select age from stud1;

AGE
----------
18
19
20
SQL> select name from
stud1;

N
-
a
b
c
SQL> select *from stud1;

N AGE
- ----------
a 18
b 19
c 20
SQL> create table
stud2(name varchar(8),age
int);

Table created.

SQL> insert into stud2


values('aaa',18);

1 row created.
SQL> insert into stud2
values('bbb',19);

1 row created.

SQL> insert into stud2


values('ccc',20);

1 row created.
SQL> select *from stud2;

NAME AGE
-------- ----------
aaa 18
bbb 19
ccc 20
SQL> create table
stud3(name varchar(8),age
number(4));

Table created.

SQL> insert into stud3


values('ccc',20);

1 row created.
SQL> select *from stud3;

NAME AGE
-------- ----------
ccc 20

SQL> select *from stud1;

N AGE
- ----------
a 18
b 19
c 20

SQL> select *from stud2;

NAME AGE
-------- ----------
aaa 18
bbb 19
ccc 20

SQL> alter table stud2


add(roll int);

Table altered.

SQL> select *from stud2;


NAME AGE
ROLL
-------- ---------- ----------
aaa 18
bbb 19
ccc 20

SQL> update stud2 set


roll=1 where age=18;
1 row updated.

SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
aaa 18 1
bbb 19
ccc 20
SQL> insert into stud2
values('ddd',20);
insert into stud2
values('ddd',20)
*
ERROR at line 1:
ORA-00947: not enough
values
SQL> insert into stud2
values('ddd',20,null);

1 row created.

SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
aaa 18 1
bbb 19
ccc 20
ddd 20

SQL> update stud2 set


roll=3 where age=20;

2 rows updated.
SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
aaa 18 1
bbb 19
ccc 20 3
ddd 20 3
SQL> update stud2 set
roll=2 where age=19;

1 row updated.

SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
aaa 18 1
bbb 19 2
ccc 20 3
ddd 20 3

SQL> delete from stud2


where age=18;

1 row deleted.
SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
bbb 19 2
ccc 20 3
ddd 20 3

SQL> truncate table stud2;


Table truncated.

SQL> select *from stud2;

no rows selected

SQL> insert into stud2


values('ddd',20,null);
1 row created.

SQL> select *from stud2;

NAME AGE
ROLL
-------- ---------- ----------
ddd 20

SQL> drop table stud2;


Table dropped.

SQL> select *from stud2;


select *from stud2
*
ERROR at line 1:
ORA-00942: table or view
does not exist
SQL>

You might also like