Anda di halaman 1dari 5

SELECT COMMAND TO CREATE A TABLE

SQL> create table temp as


2
select * from thirdmarksheet;
Table created.
SQL> select * from temp;
CODE
--------454
456
457
553
554
555
652

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------MicroProcessor & Assembly Language
85
4
Data Structure Management
94
5
Computer Organization & Archi.
94
3
Computer Peripherals & Interfacing
90
4
Computer Networks
85
4
RDBMS
85
5
Visual Basic 6.0
80
4

7 rows selected.
SQL> create table temp1 as
2
select code, credit from thirdmarksheet;
Table created.
SQL> select * from temp1;
CODE
CREDIT
--------- --------454
4
456
5
457
3
553
4
554
4
555
5
652
4
7 rows selected.
SQL> create table temp2(NewCol1, NewCol2) as
2
select course, theory_marks from thirdmarksheet;
Table created.
SQL> select * from temp2;
NEWCOL1
NEWCOL2
----------------------------------- --------MicroProcessor & Assembly Language
85
Data Structure Management
94
Computer Organization & Archi.
94
Computer Peripherals & Interfacing
90
Computer Networks
85
RDBMS
85
Visual Basic 6.0
80
7 rows selected.
SQL> create table temp3 as

2
3

select * from thirdmarksheet


where code > 500;

Table created.
SQL> select * from temp3;
CODE
--------553
554
555
652

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------Computer Peripherals & Interfacing
90
4
Computer Networks
85
4
RDBMS
85
5
Visual Basic 6.0
80
4

SQL> create table temp4 as


2
select * from thirdmarksheet
3
where 1 = 2;
Table created.
SQL> select * from temp4;
no rows selected
***********************************************************************
SELECT COMMAND TO INSERT RECORDS
SQL> create table temp as select code, course, theory_marks, credit from
firstsem;
Table created.
SQL> select * from temp;
CODE
--------266
270
271
273
355
357
451

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------Basic Electrical Engg.
85
4
Work Shop
0
1
Engg. Mathematics - I
81
3
Programming in C
98
4
Marketing Management
74
3
Fundamentals of I.T.
81
3
Electronic Devices & Circuits - I
82
5

7 rows selected.
SQL> insert into temp (select * from thirdmarksheet);
7 rows created.
SQL> select * from temp;
CODE
--------266
270
271
273
355

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------Basic Electrical Engg.
85
4
Work Shop
0
1
Engg. Mathematics - I
81
3
Programming in C
98
4
Marketing Management
74
3

357
451
454
456
457
553
554
555
652

Fundamentals of I.T.
Electronic Devices & Circuits - I
MicroProcessor & Assembly Language
Data Structure Management
Computer Organization & Archi.
Computer Peripherals & Interfacing
Computer Networks
RDBMS
Visual Basic 6.0

81
82
85
94
94
90
85
85
80

3
5
4
5
3
4
4
5
4

14 rows selected.
SQL> insert into temp (select code, course, theory_marks, credit from
secondsem);
8 rows created.
SQL> select * from temp;
CODE
--------266
270
271
273
355
357
451
454
456
457
553
554
555
652
251
255
268
272
282
452
453

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------Basic Electrical Engg.
85
4
Work Shop
0
1
Engg. Mathematics - I
81
3
Programming in C
98
4
Marketing Management
74
3
Fundamentals of I.T.
81
3
Electronic Devices & Circuits - I
82
5
MicroProcessor & Assembly Language
85
4
Data Structure Management
94
5
Computer Organization & Archi.
94
3
Computer Peripherals & Interfacing
90
4
Computer Networks
85
4
RDBMS
85
5
Visual Basic 6.0
80
4
Engg. Drawing
64
4
Essentials of Environment
58
3
Office Automation
0
2
Engg. Mathematics - II
90
3
Electronic Materials & Components
78
3
Electronic Devices & Circuits - II
83
5
Digital Electronics
82
4

CODE COURSE
THEORY_MARKS
CREDIT
--------- ----------------------------------- ------------ --------455 Programming in C++
89
4
22 rows selected.
SQL> select * from temp order by code;
CODE
--------251
255
266
268
270
271
272

COURSE
THEORY_MARKS
CREDIT
----------------------------------- ------------ --------Engg. Drawing
64
4
Essentials of Environment
58
3
Basic Electrical Engg.
85
4
Office Automation
0
2
Work Shop
0
1
Engg. Mathematics - I
81
3
Engg. Mathematics - II
90
3

273
282
355
357
451
452
453
454
455
456
457
553
554
555

Programming in C
Electronic Materials & Components
Marketing Management
Fundamentals of I.T.
Electronic Devices & Circuits - I
Electronic Devices & Circuits - II
Digital Electronics
MicroProcessor & Assembly Language
Programming in C++
Data Structure Management
Computer Organization & Archi.
Computer Peripherals & Interfacing
Computer Networks
RDBMS

98
78
74
81
82
83
82
85
89
94
94
90
85
85

4
3
3
3
5
5
4
4
4
5
3
4
4
5

CODE COURSE
THEORY_MARKS
CREDIT
--------- ----------------------------------- ------------ --------652 Visual Basic 6.0
80
4
22 rows selected.
***********************************************************************
SELECT COMMAND FOR COLUMN ALIASES
SQL> select code subject_code , course Course_Name from temp;
SUBJECT_CODE
-----------266
270
271
273
355
357
451
454
456
457
553
554
555
652
251
255
268
272
282
452
453

COURSE_NAME
----------------------------------Basic Electrical Engg.
Work Shop
Engg. Mathematics - I
Programming in C
Marketing Management
Fundamentals of I.T.
Electronic Devices & Circuits - I
MicroProcessor & Assembly Language
Data Structure Management
Computer Organization & Archi.
Computer Peripherals & Interfacing
Computer Networks
RDBMS
Visual Basic 6.0
Engg. Drawing
Essentials of Environment
Office Automation
Engg. Mathematics - II
Electronic Materials & Components
Electronic Devices & Circuits - II
Digital Electronics

SUBJECT_CODE COURSE_NAME
------------ ----------------------------------455 Programming in C++
22 rows selected.
SQL> select code "Subject Code", course "Course Name" from temp;
Subject Code Course Name

-----------266
270
271
273
355
357
451
454
456
457
553
554
555
652
251
255
268
272
282
452
453

----------------------------------Basic Electrical Engg.


Work Shop
Engg. Mathematics - I
Programming in C
Marketing Management
Fundamentals of I.T.
Electronic Devices & Circuits - I
MicroProcessor & Assembly Language
Data Structure Management
Computer Organization & Archi.
Computer Peripherals & Interfacing
Computer Networks
RDBMS
Visual Basic 6.0
Engg. Drawing
Essentials of Environment
Office Automation
Engg. Mathematics - II
Electronic Materials & Components
Electronic Devices & Circuits - II
Digital Electronics

Subject Code Course Name


------------ ----------------------------------455 Programming in C++
22 rows selected.

Anda mungkin juga menyukai