export TNS_ADMIN=$PWD/tns_admin
orcl19c % export TNS_ADMIN=$PWD/tns_admin
orcl19c %
unzip v23.3.zip
orcl19c % curl -OL https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v23.3.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 11.6M 0 11.6M 0 0 3600k 0 --:--:-- 0:00:03 --:--:-- 4046k
orcl19c % unzip v23.3.zip
Archive: v23.3.zip
e3325a83e56c516815844025418a96ecaf219751
creating: db-sample-schemas-23.3
extracting: db-sample-schemas-23.3/.gitignore
inflating: db-sample-schemas-23.3/LICENSE.txt
inflating: db-sample-schemas-23.3/README.md
inflating: db-sample-schemas-23.3/README.txt
inflating: db-sample-schemas-23.3/SECURITY.md
creating: db-sample-schemas-23.3/customer_orders
[中略]
inflating: db-sample-schemas-23.3/sales_history/sh_populate.sql
inflating: db-sample-schemas-23.3/sales_history/sh_uninstall.sql
inflating: db-sample-schemas-23.3/sales_history/supplementary_demographics.csv
inflating: db-sample-schemas-23.3/sales_history/times.csv
orcl19c %
cd db-sample-schemas-23.3/human_resources
@hr_install
orcl19c % cd db-sample-schemas-23.3/human_resources
human_resources % sql sys@localhost/orclpdb1 as sysdba
SQLcl: 月 9月 01 13:03:39 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
パスワード (**********?) ******
接続先:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0
SQL> @hr_install
Thank you for installing the Oracle Human Resources Sample Schema.
This installation script will automatically exit your database session
at the end of the installation or if any error is encountered.
The entire installation will be logged into the 'hr_install.log' log file.
Enter a password for the user HR: ******
Enter a tablespace for HR [USERS]:
Do you want to overwrite the schema, if it already exists? [YES|no]:
****** Creating REGIONS table ....
Table REGIONSは作成されました。
INDEX REG_ID_PKは作成されました。
Table REGIONSが変更されました。
****** Creating COUNTRIES table ....
Table COUNTRIESは作成されました。
[中略]
コミットが完了しました。
Installation verification
____________________________
Verification:
Table provided actual
______________ ___________ _________
regions 5 5
countries 25 25
departments 27 27
locations 23 23
employees 107 107
jobs 19 19
job_history 10 10
Thank you!
___________________________________________________________
The installation of the sample schema is now finished.
Please check the installation verification output above.
You will now be disconnected from the database.
Thank you for using Oracle Database!
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0から切断されました
human_resources %
データベース・ユーザーRASADMINを作成し、最低限必要な権限を与えます。作業はユーザーSYSで実施します。
alter user rasadmin quota 25m on users;
grant create session to rasadmin;
grant create table, create procedure to rasadmin;
orcl19c % sql sys@localhost/orclpdb1 as sysdba
SQLcl: 月 9月 01 13:07:58 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
パスワード (**********?) ******
接続先:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0
SQL> create user rasadmin identified by ********;
User RASADMINは作成されました。
SQL> alter user rasadmin quota 25m on users;
User RASADMINが変更されました。
SQL> grant create session to rasadmin;
Grantが正常に実行されました。
SQL> grant create table, create procedure to rasadmin;
Grantが正常に実行されました。
SQL>
ユーザーRASADMINに、Real Application Securityを構成するために必要な権限を与えます。パッケージXS_ADMIN_CLOUD_UTILの代わりにXS_ADMIN_UTILを呼び出します。
begin
sys.xs_admin_util.grant_system_privilege('PROVISION','RASADMIN');
sys.xs_admin_util.grant_system_privilege('ADMIN_ANY_SEC_POLICY','RASADMIN');
end;
/
SQL> begin
2 sys.xs_admin_util.grant_system_privilege('PROVISION','RASADMIN');
3 sys.xs_admin_util.grant_system_privilege('ADMIN_ANY_SEC_POLICY','RASADMIN');
4 end;
5* /
PL/SQLプロシージャが正常に完了しました。
SQL>
ロールHR_ROLEを作成し、ユーザーRASADMINに割り当てます。ロールHR_ROLEは後ほど、ユーザーRASADMINが作成したアプリケーション・ロールEMPLOYEEに割り当てます。
create role hr_role;
grant select on hr.departments to hr_role;
grant select on hr.employees to hr_role;
grant select on hr.jobs to hr_role;
grant select on hr.job_history to hr_role;
grant select on hr.locations to hr_role;
grant select on hr.regions to hr_role;
grant select on hr.countries to hr_role;
grant select on hr.emp_details_view to hr_role;
grant hr_role to rasadmin with admin option;
SQL> create role hr_role;
Role HR_ROLEは作成されました。
SQL> grant select on hr.departments to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.employees to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.jobs to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.job_history to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.locations to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.regions to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.countries to hr_role;
Grantが正常に実行されました。
SQL> grant select on hr.emp_details_view to hr_role;
Grantが正常に実行されました。
SQL> grant hr_role to rasadmin with admin option;
Grantが正常に実行されました。
SQL>
begin
sys.xs_admin_util.grant_system_privilege('ADMINISTER_SESSION','MCPUSER');
end;
/
SQL> begin
2 sys.xs_admin_util.grant_system_privilege('ADMINISTER_SESSION','MCPUSER');
3 end;
4* /
PL/SQLプロシージャが正常に完了しました。
SQL>
grant select any table on schema hr to mcpuser;
今回はこの権限は与えません。ロールHR_ROLEはRASの動的ロールEMPLOYEEとしてRASユーザーに割り当てられるため、必ずしもユーザーMCPUSERが同じ権限を持つ必要はありません。
動作確認
ORCLPDB1_TLS_OAUTH =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCPS)(HOST = 0.0.0.0)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLPDB1)
)
(SECURITY =
(SSL_SERVER_DN_MATCH=TRUE)
(SSL_SERVER_CERT_DN="CN=orcl19c")
(TOKEN_AUTH=OAUTH)
(TOKEN_LOCATION=/Users/________/Documents/orcl19c/token.txt)
)
)
az login --tenant "テナントID" --scope "アプリケーションIDのURI/session:scope:connect"
ブラウザのサインイン画面が開きます。以下はすでにサインイン済みだったので、アカウントの選択のみを求められています。サインインするユーザーを選択します。
orcl19c % az login --tenant "********-****-****-****-************" --scope "https://_________outlook.onmicrosoft.com/********-****-****-****-************/session:scope:connect"
A web browser has been opened at https://login.microsoftonline.com/********-****-****-****-************/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Retrieving subscriptions for the selection...
[Tenant and subscription selection]
No Subscription name Subscription ID Tenant
----- -------------------- ------------------------------------ ------------------------------------
[1] * Azure subscription 1 ********-****-****-****-************ ********-****-****-****-************
The default is marked with an *; the default tenant is '********-****-****-****-************' and subscription is 'Azure subscription 1' (********-****-****-****-************).
Select a subscription and tenant (Type a number or Enter for no changes):
Tenant: ********-****-****-****-************
Subscription: Azure subscription 1 (********-****-****-****-************)
[Announcements]
With the new Azure CLI login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236
If you encounter any problem, please open an issue at https://aka.ms/azclibug
[Warning] The login output has been updated. Please be aware that it no longer displays the full list of available subscriptions by default.
ynakakoshi@Ns-Macbook orcl19c %
az account get-access-token --scope "アプリケーションIDのURI/session:scope:connect" --query accessToken -o tsv > token.txt
orcl19c % az account get-access-token --scope "https://________outlook.onmicrosoft.com/********-****-****-****-************/session:scope:connect" --query accessToken -o tsv > token.txt
orcl19c %
conn -save orclpdb1_tls_oauth -savepwd /@orclpdb1_tls_oauth
select sys_context('userenv','authentication_method') from dual;
exit
orcl19c % sql /nolog
SQLcl: 月 9月 01 14:01:05 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
SQL> conn -save orclpdb1_tls_oauth -savepwd /@orclpdb1_tls_oauth
名前: orclpdb1_tls_oauth
接続文字列: orclpdb1_tls_oauth
ユーザー:
パスワード: 未保存
接続しました.
SQL> select sys_context('userenv','authentication_method') from dual;
SYS_CONTEXT('USERENV','AUTHENTICATION_METHOD')
_________________________________________________
TOKEN_GLOBAL
SQL> exit
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0から切断されました
orcl19c %
npx -y @modelcontextprotocol/inspector
ブラウザにMCP Inspectorの画面が開きます。
orcl19c % npx -y @modelcontextprotocol/inspector
Starting MCP inspector...
⚙️ Proxy server listening on localhost:6277
🔑 Session token: c2381f2821873d9179a38ee659ec7ba12796fe14093229ecd912d7ff4022f954
Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth
🚀 MCP Inspector is up and running at:
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=c2381f2821873d9179a38ee659ec7ba12796fe14093229ecd912d7ff4022f954
🌐 Opening browser...
MCP Inspectorの画面で以下の設定を行ないます。
select * from hr.employees