Search code examples
oracle-databaseoracle11gdatabase-administrationoracle-xe

Oracle SYSDBA connection


When we connect to Oracle database for the first time from SQLPlus command line tool, why do we always connect like this

"sys as sysdba"

Can some one tell me the significance of this?

Why do not we do this in MYSQL?

I am new to Oracle, and this question might sound silly. I am learning using Oracle 11g XE.


Solution

  • SYS and SYSTEM are administrative users, they kind of "own" the database. Data dictionary is stored in SYS schema so - if you screw it up, you'll most probably destroy the database. Therefore, never mess up with it - use it only for necessary administrative tasks. Never touch any SYS owned tables (thinking "if I change this I'll make that happen). Even better, create your own user and grant it DBA privilege - it'll be able to do mostly everything you'd ever want.

    SYSDBA is a privilege which is automatically granted to user SYS; it lets it perform high-level administrative tasks (such as backup and recovery or upgrade the database). SYSTEM doesn't have it; that's why you don't specify as sysdba when connecting as SYSTEM.

    Furthermore, SYSDBA privilege lets you to connect to database instance although database isn't open yet - and lets you start it up.


    Saying that you "always connect as sys as sysdba" - well, you don't have to do that "always". There are other predefined users (such as Scott or HR (Human Resources)) you can use. Default username/password combinations are "scott/tiger" and "hr/hr". Though, they are most probably locked so you can't establish connection. That's why you connect as SYS, unlock those accounts (or create new one(s), depending on what you want to do), and then connect as some other user.


    More info here:


    Why you don't have that in MySQL? Probably because MySQL isn't Oracle.


    Finally, as you're new with Oracle, I'd suggest you to visit & bookmark this page: Oracle Database 10gR2 documentation. Yes, it is kind of "old" and you don't use that version, but it is the last one that separated "Getting Started" and "Most popular" books which makes it easy to find and read. I'd suggest you to read:

    • Concepts, to learn what Oracle is and how it works

    Then, depending on what you'd want to do/be (developer or DBA), pick e.g.

    • 2 day DBA
    • Administrator's guide

    or

    • SQL reference
    • PL/SQL user's guide and reference
    • Application developer's guide - fundamentals

    Certainly, you can find these books for database version you do use (11g), it is here: Oracle database online documentation 11g Release 2 (11.2) but - as I said - it is not as nicely presented as 10g.

    Good luck with Oracle, enjoy!