Installation process of utPLSQL - oracle

I am trying to setup utPLSQL for writing a unit test for PLSQL project.
I am running into error while installing.
I am not getting how to install it.
Could anyone give a step by step procedure to install utPLSQL ?
Thanks

From http://utplsql.sourceforge.net/Doc/fourstep.html
It looks rather simple, but you must connect to sqlplus as SYSTEM - a power user on your database that will be able to create the UTP user.
SQL> connect system/< the system's password >
SQL> create user utp identified by utp default tablespace
users temporary tablespace temp;
SQL> grant create session, create table, create procedure,
create sequence, create view, create public synonym, drop public synonym to utp;
SQL> alter user utp quota unlimited on users;
Then only run
SQL> ut_i_do install

Related

Oracle Role for liquibase user

I am working on adding liquibase in my spring boot app which connects to an oracle DB. I don't feel comfortable using the schema ID in my application. So I would like to create another user id that will be used to connect to the DB from my app. Since I am using liquibase this new user id will need to have create, drop, select, insert, update, delete on all table in that schema.
In Mysql I can ran the following command:
GRANT CREATE, DROP, SELECT, INSERT, UPDATE, DELETE ON SCHEMA_NAME.* TO 'liquidbase_local_usr'#'localhost';
is there a similar query in Oracle?
I did this with the Datical product that was built on Liquibase.
First I created a role called DATICAL_PACKAGER_ROLE and assigned it to the user $DaticalUser:
CREATE ROLE DATICAL_PACKAGER_ROLE NOT IDENTIFIED;
-- When using the tracefileLocation=REMOTE, you will need to setup the following permissions.
-- Note: These permissions are only required on schemas running the Convert SQL Scripts command. This is only needed on the packaging / reference database.
GRANT EXECUTE ANY PROCEDURE TO DATICAL_PACKAGER_ROLE;
GRANT ALTER SESSION TO DATICAL_PACKAGER_ROLE;
GRANT CREATE ANY DIRECTORY TO DATICAL_PACKAGER_ROLE;
GRANT DROP ANY DIRECTORY TO DATICAL_PACKAGER_ROLE;
-- The following permissions are needed for backing up and restoring the database. This is only needed on the packaging / reference database.
GRANT EXP_FULL_DATABASE TO DATICAL_PACKAGER_ROLE;
GRANT IMP_FULL_DATABASE TO DATICAL_PACKAGER_ROLE;
-- The following must be run as sysdba
-- SQL > conn / as sysdba
GRANT EXECUTE on SYS.UTL_FILE TO DATICAL_PACKAGER_ROLE;
-- Grant the new role to the Datical User
GRANT DATICAL_PACKAGER_ROLE to $DaticalUser;
Then I granted the role to the schema I wanted:
GRANT DATICAL_PACKAGER_ROLE to <yourschema>;

How to create a database user for oracle 11g on windows 8?

I am new to oracle database and therefore is trying to follow the office guide. (link to the guide) However, it seems that the guide is for Windows 7, so in step 2 - creating database user, it says:
Display the SQL command prompt window. For example, on Windows, click Start, then Programs (or All Programs), then Oracle Database 11g
Express Edition, and then Run SQL Command Line.
And in windows 8, there is not start button. I try to search the menu using keyword oracle but nothing with similar name is found. I tried to go to the Program Files directly but also no similar file found. So, how should I create a database user on Windows 8?
I don't use Windows 8, but I guess that it must have some kind of a "command prompt" (you know, a program that lets you perform text-based (command-line) functions; its window is black with white letters. Once opened, the cursor blinks at the prompt, waiting for your commands). Try to find it, run it.
Then you'll be able to connect to your database (you do have it installed, right?) as
C:\> sqlplus sys/your_sys_password#database as sysdba
You'll be connected as SYS (be careful! It is a powerful user and its misuse might break your database! I'd suggest you to create another user, for example "mydba", grant it DBA role and let it perform DBA actions).
If you're unsure of what your tablespaces are, run
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USER_DATA
APEX
APEX_9695076087226093
7 rows selected.
SQL>
as you'll need at least two of them. Now create your new user:
SQL> create user mike identified by lion
2 default tablespace user_data
3 temporary tablespace temp
4 profile default
5 quota unlimited on user_data;
User created.
SQL> grant create session to mike;
Grant succeeded.
SQL>
Granting create session, it'll be able to connect to the database, but won't be able to do anything else, so you'd have to grant it some more privileges (such as create table, create view, create procedure etc.).
SQL> connect mike/lion#orcl
Connected.
SQL> create table test (id number);
create table test (id number)
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>

How to create schema in Oracle and table spaces?

I create user(schema) in oracle. like this
create user EMP_DB identified by netsolpk account unlock;
But when i tried login through schema name and password, login failed. Below is the error message.
user EMP_DB lacks create session privilage; login denied.
I've not created any tablespaces.
For this, do I need to create any tablespace? If needed, how to create a tablespace?
And what more things are required for creating a schema in oracle 11g.
Please help me and give me step by step procedure.
The error user EMP_DB lacks create session privilage; login denied indicates that you need privilege to create a session. So you need to grant the appropriate privilege like,
GRANT CREATE SESSION TO emp_db;
Or You can go with granting the roles(group of privileges), CONNECT and RESOURCE.
CONNECT role has only CREATE SESSION privilege.
RESOURCE has the following privilges,
CREATE TRIGGER
CREATE SEQUENCE
CREATE TYPE
CREATE PROCEDURE
CREATE CLUSTER
CREATE OPERATOR
CREATE INDEXTYPE
CREATE TABLE
To find these PRIVILEGES of a ROLE, You can query the DBA_SYS_PRIVS table with a query like this:
SELECT grantee, privilege, admin_option
FROM DBA_SYS_PRIVS
WHERE grantee='RESOURCE';
Also to use the existing tablespace USERS, You can create a user with QUOTA UNLIMITED statement like,
CREATE USER emp_db IDENTIFIED BY netsolpk QUOTA UNLIMITED on USERS;
the fastest, quickest way to create a new user with privileges is
grant connect, resource to NewUser_name identified by NewUser_password;
by this command you will be sure that errors like above will not displayed.

Why do I need a common account in Oracle?

Why do I need a common account in Oracle 12c? A common means a CDB account. When I create an account using enterprise manager express it's creating only common accounts. Could I create a non-common account there? A common user also appears in every container I ever switch/connect to. What's the purpose of this common account to access all those pluggable databases?
Why do I need a common account in Oracle 12c?
What's the purpose of this common account to access all those pluggable databases?
You need a common account(common user) to perform administrative operations on CDB(container database) such as changing the state of a pluggable database, plugging and unplugging pluggable databases (PDBs) and so forth, which local user cannot do. Well, in fact, a local user can change state of pluggable database as well, but only PDB it connected to as sysdba or sysoper.
Could I create a non-common account there(in CDB)?
No, non-common account(Local user) cannot be created in the root - can only be created and operate within a pluggable database(PDB) and wont have access(you cannot use it to log in to) CDB or other PDBs.
Find out more
about commonality and common and local users.
Edit
CDB$ROOT is root container. PDB$SEED is just a template needed to create a pluggable databases. You cannot create or modify objects in it. PDBORCL is a pluggable database, which you should use for your development.
Oracle will throw the ORA-01033 error if you are trying to connect to a closed PDB as non sysdba user. Usually, PDBs database are not open by default, just mounted (unless your have automated that process by creating a trigger, for example, that will do it for you upon starting up CDB) and you need to explicitly open it while connecting as a common user (SYS or other common user that has the privilege to startup/alter pluggable database) and issue:
SQL> alter pluggable database <<name_of_PDB>> open;
or
SQL> startup pluggable database <<name_of_PDB>>
After that you should be able to connect to your PDB as common or local user. Of course they have to have appropriate privileges(create session) to be able to do so.
Edit #2 Automating starting up of pluggable database(s) on startup of CDB using system event(after startup on database) trigger. Unfortunately there is no native way to startup PDs automatically.
SQL> conn / as sysdba
Connected.
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 NKRASNOV READ WRITE NO
This specific trigger opens one pluggable database. If you have more than one PDs and want to open them all, the alter statement can be modified as follows ALTER PLUGGABLE DATABASE ALL OPEN;
SQL> create or replace trigger open_pdb
2 after startup on database
3 begin
4 execute immediate 'alter pluggable database nkrasnov open';
5 end;
6 /
Trigger created.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 NKRASNOV READ WRITE NO
SQL> conn hr/hr#nkrasnov_pdb
Connected.
SQL> spool off;

Syntax to Create User On Another Server via DB Link

I'd like to create a user on another server using a db link. Is this possible? (Lets assume I have permission)
Here's the syntax for creating a user on the local server
create user TEST_USER
identified by TEST_USER_PW
default tablespace USERS
temporary tablespace TEMP;
How could it be done with a db link?
Thank you (Feel free to migrate this to DBA if it's off topic)
Edit: Haki brought up that DDL operations are not allowed on a remote database. I'll post an alternative once I find one.
You can execute DDL on over a database link using DBMS_UTILITY.EXEC_DDL_STATEMENT:
begin
dbms_utility.exec_ddl_statement#myself(
'create user TEST_USER
identified by TEST_USER_PW
default tablespace USERS
temporary tablespace TEMP');
end;
/

Resources