I have installed Oracle 11g Express Edition and am using using SQL Developer.
I have created two schemas but forgotten the password - is there any way to unlock them?
quite straightforward question....login as sysdba
sql>connect / AS sysdba
sql>alter user <use_name> identified by <Password>
ex:alter user xyz identified by stackover --don't enclose by quatos
Related
I just finished installing oracle 18c express edition on windows 8 laptop. During the installations, I did not enter any user name. I entered my password though.
At the end of the installation, I get this screen:
I connected Oracle database using sql plus as follows:
SQL> / as sysdba
I also entered the following commands in sql plus and all have worked. I was just following youtube tutorial without understanding everything.
SQL>alter pluggable database all open;
SQL>alter pluggable database all save state ;
SQL>select name from v$pdbs;
SQL> connect sys/oracle#localhost:1521/XEPDB1 as sysdba;
SQL> alter user hr identified by hr;
SQL> alter user hr account unlock;
SQL>connect hr/hr#localhost:1521/XEPDB1;
SQL> select * from employees;
SQL> CREATE TABLE TEST1 (CUSID NUMBER(10) NOT NULL);
This is the first time I am doing it. I tried to connect to a database using SYS as the user name and the password but did not connect.
SQL> Enter user name: SYS;
Enter password: Welcome1
SYS - During the installation, it said sys, system, and pdbadmin accounts. So I assume sys could be one of the user names.
Password - I entered the same password I used at the time of installation. I can connect to the database using / as sysdba. But I am not sure what this code meaning and what the user name and password and what database it is trying to connect. What would be the database name, user name and password?
Update 1
I created a connection in sql developer. Below shows the connection properties.
I created a table(sqldev2) in sql developer, inserted rows, and selected the data just fine.
Next, I went to sql plus and tried to select the same data from sqldev2 table but it shows no rows selected. I am assuming sql plus and sql developer may be pointing to two different databases?
How can I tell which database I am connected using the sql developer?
How can I connect to the same database using the sql plus?
This way I can work on the same database using the sql plus and sql developer.
Update 2
In Eclipse IDE, I had this code to connect to database. After that, I created a table (testtble) in Eclipse.
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521/xe", "sys as sysdba","pw");
In SQL Plus, I connected to the db using "/ as sysdba". After that, I also tried to select * from testtble but it shows no table. I am assuming sql plus might be pointing to something different than what I used in eclipse. How should I connect to the database from SQL plus so I could see the table "testtble" in sql plus?
To check in which pluggable database you are currently connected in SQL*Plus use:
show con_name
If you connect to Oracle using a connect string that is using a database service mapped to a pluggable database (PDB), you will be connected directly to the related PDB.
Try different connections strings and check with show con_name.
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.
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:
SYS and SYSTEM users
SYSDBA and SYSOPER system privileges
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!
Trying to unlock SCOTT in oracle 19c.
alter user scott account unlock identified by tiger;
ERROR Message:
ORA-01918: user 'SCOTT' does not exist
From documentation:
Starting from Oracle 12cR2, only HR schema is provided via installation. All other sample schema scripts are available on GitHub at https://github.com/oracle/db-sample-schemas/releases/latest
SCOTT schema is no longer provided in the sample schemas, you could manually create it using the scripts from older Oracle versions or use the HR and other sample schemas.
Once you install the sample schemas manually in PDB, you could then unlock them and use. See Oracle Multi-tenant DB Post Installation Mandatory Steps
In ORACLE 19C How TO CHANGE sysdba password.
whenever I'm trying to connect with scott it is showing invalid username/password,
tried this:
alter user scott account unlock;
SP2-0640: Not connected
alter user scott identified by tiger;
SP2-0640: Not connected
Go to the Installing path of the Oracle 11g In default it is present C: Drive, then move to C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin
here you can find a file named scott.sql
Open the SQL Command Line and login as conn system/ (password set during the installation of oracle 11g)
Run the Below script (Note: File name is appended at the end)
# C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin\scott.sql
Now you can query the SELECT * FROM all_users; to see the scott schema created
Alternatively you can do this by using SQL developer by creating a connection to SYSTEM and run the above script
After the creation the default username : SCOTT password: TIGER
In the comment part i especially asked for querying
select count(1) from dba_users where username = 'SCOTT';. I'd like to learn if user exists.
For the message you get ORA-01017,
the First possible reason is what message tells us(invalid
username/password).
Secondly, you may not have an account named SCOTT. i.e. the above
query gives 0(zero).
In this case :
you should create mentioned user ( when you're connected to system ):
SQL> conn system/pwd
Connected.
SQL> create user scott identified by tiger;
and grant related privileges :
SQL> grant connect to scott;
SQL> grant resource to scott;
and then you can connect by issuing :
SQL> conn scott/tiger
Connected.
Connect with a DBA Account and Issue an Alter User Command
The error you are seeing indicates you are no longer connected to the database. You were logged in as system#db, but when you tried to connect as scott#db, you no longer have a database connection.
Here I replicate your experience:
SYSTEM#db>conn system#db as sysdba
Enter password:
Connected.
SYS#db>conn scott#db
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied
#>alter user account scott unlock;
SP2-0640: Not connected
#>alter user scott identified by tiger;
SP2-0640: Not connected
Here I reconnect and then issue an alter user command to unlock the user account and set a new password.
#>conn system#db as sysdba
Enter password:
Connected.
SYS#db>ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
User altered.
SYS#db>conn scott/tiger#db
Connected.
Addendum
My steps provided assumed you had the scott schema installed. If the scott schema does not exist, it would be good to see if the default 11g database sample schemas exist.
The schema account scott is no longer a default schema in the 11g database. The 11g documentation states:
"Oracle used the schema SCOTT with its two prominent tables EMP and
DEPT for many years. With advances in Oracle Database technology,
these tables have become inadequate to show even the most basic
features of Oracle Database and other Oracle products. "
I would recommend reviewing to see if the other default sample schemas are installed. The hr account is most similar to the scott schema.
Here is a list of common sample schema usernames:
username IN (
'HR',
'OE',
'PM',
'SH',
'IX'
)
Check to see if the person whom performed the installation used the database configuration assistant and opted to install the sample schemas.
If the schemas were not created at the time of installation, the document, "Oracle® Database Sample Schemas 11g Release 1 (11.1) B28328-03", describes the steps to do this in chapter 2, Installation.
Open Oracle sql developer.
In the sql developer paste the path of scott.sql file(C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin\scott.sql) with '#' infront of it.
# C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin\scott.sql
Run script
Script Output -> Connection created by CONNECT script command disconnected
Connect using SQL Command Line
conn scott/TIGER;
I have installed Oracle 11g on Windows 7
When I start sqlplus, it ask me for a username and password
Can anybody tell me what username needs to be inserted and when I try to type in any password, it doesn't allow me to type a single letter. Is there a reason why?
If you've forgotten the password for any user then you can reset by logging in as SYS:
sqlplus / as sysdba
And then:
alter user <username> identified by <password>;
If you've forgotten which users you have then you can run:
select username from all_users;
If you have only recently created the database it would be worthwhile restricting on CREATED, as the default database install comes with dozens of its own schemas. For instance, to find users added in the last week run this:
select * from all_users
where created > trunc(sysdate)-7;
Enter SYSTEM as user-name and the password entered during installing 11g works well for me!
The username refers to the schema to which you must connect to. Generally the hr schema is the sample schema that is available. The password will be the same password that you set during Oracle installation.