Index作るSQL

gihyo.jp

↑の5章の最後でIndex作るSQL

 

***

create table order_app.tbl_customer
(
customer_no number(4) not null,
customer_name varchar2(40 char) not null,
customer_address varchar2(200 char) not null,
constraint pk_customer_no primary key (customer_no)
)
tablespace order_tbs
;

create table order_app.tbl_product
(
product_no char(6) not null,
product_name varchar2(40 char) not null,
price number(10) not null check (price > 0),
constraint pk_product_no primary key (product_no),
constraint uq_product_name unique (product_name)
)
tablespace order_tbs
;

create table order_app.tbl_order
(
order_no number(4) not null,
order_date date not null,
pay_type varchar2(10 char) not null check (pay_type in ('現金払い','銀行振込')),
customer_no number(4) not null,
constraint pk_order_no primary key (order_no),
constraint fk_order_customer_no foreign key (customer_no)
references order_app.tbl_customer (customer_no)
)
tablespace order_tbs
;

create table order_app.tbl_order_item
(
order_no number(4) not null,
order_item_no number(5) not null,
product_no char(6) not null,
order_num number(10) not null check (order_num > 0),
item_account number(10) not null check (item_account > 0),
constraint pk_order_item_no primary key (order_no, order_item_no),
constraint fk_order_item_order_no foreign key (order_no)
references order_app.tbl_order (order_no),
constraint fk_order_item_product_no foreign key (product_no)
references order_app.tbl_product (product_no)
)
tablespace order_tbs
;

create index order_app.idx_order_date on order_app.tbl_order (order_date)
tablespace order_tbs
;

CentOS8へのOracle19cインストール。ついでにWin10へのOracleClientインストール。

 

●CentOS8

VMware Workstation Player上に構築した(ホストはWin10)

 →NWはブリッジ(複製)

 →nmcli connection modify ens33 connection.autoconnect yes

 →nmcli con up ens33(またはeth0)

  →ip addressでIP確認 

 ---

 

●Oracle19cインストール

【参考】CentOS 8 : Oracle Database 19c : インストール環境の設定 : Server World

・DB名はデフォルト「orcl」にしといた

TeratermCentOS(cui,gui)を行ったり来たりしながらやった

・最後のsqlplusは下記コマンドで入った

 sqlplus sys@orcl as sysdba

 

Oracle Client インストール(Windows10)

【参考】Windows10(64bit)にOracle Instant ClientをインストールしSQL*Plusを使えるようにする手順 - そういうのがいいブログ

・下記コマンドでログイン成功

sqlplus sys/[PW]@[IP]:1521/orcl as sysdba