tags:

views:

246

answers:

3
 select sys.database_name,sys.sysevent,sys.login_user from dual;

what is sys in this query?


Can I see the other functions that are in sys?
What is the query for doing so?
In what situations is this sys useful?
Where will be the information about sys is stored in database?

+2  A: 

sys is the system schema. It holds various tables and views that support the rdbms.

You might check out the oracle wiki article which talks about the various schemas and their meaning.

http://en.wikipedia.org/wiki/Oracle_database

Chris Lively
Clear and to the point +1. However , I might have used this link instead : http://www.techonthenet.com/oracle/sys_tables/index.php
Learning
+2  A: 

In many database systems, including the major database products from Oracle, Microsoft and Sybase, groups of related database tables can be pulled together into a schema.

Some large systems (and, for that matter, some not so large systems) use this as a way to control access, or just as a way to keep things well organised.

For example, the tables supporting an online catalog (e.g. Amazon or Barnes & Nobel) might all be Marketing.*, the tables around order fulfillment Sales.* and those around Stock management Stock.*.

The sys schema that you've noticed is where system tables live - tables that you can query to find out details about the rest of the database - such as whether a column already exists.

Bevan
+2  A: 

I agree with Bevan. Here are some answers specific to your questions:

(I'll make the assumption you're talking about Oracle)

Can I see the other functions that are in sys?

Yes, like any schema you can view the procedures, functions and packages in sys using a database development tool such as Toad, PLSQL Developer or Oracle SQL Developer. However my experience has shown that referring to Oracle documentation (freely available online) is a better way to learn about the available functionality than jumping straight to the source code.

What is the query for doing so?

I'd recommend the use of one of the development tools above. Failing that, try:

select * from user_objects where type in ('PACKAGE', 'PROCEDURE', 'FUNCTION');

Once you've found the functionality you're looking for use the DESCRIBE command in SQLPlus to determine the method signatures and data types.

In what situations is this sys useful?

SYS is most often often used as a super user for adminstrative tasks as it has more privileges than a common schema. SYS also contains a lot of the infrastructure on which Oracle depends - don't mess around with the objects that SYS owns.

Where will be the information about sys is stored in database?

Use the methods I have suggested above - but I recommend you read the online documentation rather than dive straight into the source.

darreljnz
Just a note, querying USER_OBJECTS will only return objects owned by the currently logged-in user. If you're logged in as SYS, then yes USER_OBJECTS will help; otherwise, you'd need to query DBA_OBJECTS or ALL_OBJECTS for objects owned by SYS.
Jeffrey Kemp