Tải bản đầy đủ (.pdf) (26 trang)

Lesson Working with Oracle

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (672.86 KB, 26 trang )

statements in SQL*Plus.
• Refer to SQL*Plus User’s Guide for Documentation
• Enter the following:

SQL> set property_name new_value

• Example of a set of statements to customize SQL*Plus:
SQL>
SQL>
SQL>
SQL>
SQL>

set
set
set
set
set

linesize 132
pagesize 100
echo on
long 4000
autocommit off

Generating Output
To generate output to a file, enter:
SQL> spool path_to_file

• This writes everything into the file at given path.
– Use the following command to see what is being


written to the file:
set echo on
• If the file has no extension, .lst is created.
• It overwrites the existing file.
To buffer writes and stop spooling of output, enter
SQL> spool off

Unix Overview

21


Customizing Output
To customize output, enter:
SQL> column column_name format format

This changes the default length and format of column output.
SQL> select bu_nam from cz_bus_unit where bu_unit = 0;
BU_NAM
---------------------------------------SYSTEM
SQL> column bu_nam format a10
SQL> /
BU_NAM
---------SYSTEM

Working with Oracle

Basic SQL Commands

Unix Overview


22


Basic Commands
Command description

SQL Command

Show user

show user;

List tables in current
schema

select table_name from user_tables;

List tables current user select table_name from all_tables
has access to
See table description

desc <tablename>;

Repeat last command

/

Basic Commands
Command description


SQL Command

Set number lines per
page to n

Set pagesize n
(no semicolon used)

Set number columns
to n

Set linesize n
(no semicolon used)

Count the rows of a
table

select count(*) from <tablename>;

List the top n rows of a select * from
table in order
(select * from <tablename>
order by <columnname>)
where rownum <= n;

Unix Overview

23



Basic Commands
Command description

SQL Command

Request all information
from a table

select *
from <tablename>;

Request a column of
select <columnname>
information from a table from <tablename>;
Request information
based on a condition

select <columnname>
from <tablename>
where <condition>;

Sort the output

select <columnname>
from <tablename>
where <condition on column>
order by <sorting column>;

Basic Commands

Command description

SQL Command

Insert information into a insert into <tablename>
table
values ( <complete list of values> );
Update a column in
every row

update <tablename>
set <column name> = <value>;

Update a column based update <tablename>
on a condition
set <column name> = <value>
where <codition>;
Commit any changes to commit;
the database before
exiting

Unix Overview

24


Basic Commands
Command description

SQL Command


You can use aliases to
abbreviate table names
in commands

select tn.<columnname>
from <tablename> tn
where tn.<columname> = <value>;

You can use compound where <columnname1> = <value1>
conditions in the
and <columnname2> = <value2>;
WHERE clause
Accept a table name
from the keyboard and
then use in another
command. These are
separate commands

accept tabl
prompt ‘Enter table name

’;

select * from &tabl;

Module Summary
At the end of this module, you have learned:











Unix Overview

Basic commands of korn Shell
User permission and file permission in Unix
Basic functions in Unix
Useful commands in Unix
Vi editor commands
Database concepts
SQL commands
Use of SQL*Plus

25


Unix Overview

26



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×