SQL*Plus: Release 11.2.0.1.0 Production on 星期五 10月 9 13:23:09 2020
Copyright (c) 1982, 2010, Oracle. All rights reserved.
请输入用户名: system@study
输入口令:
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
ORCLTBSL_210 ONLINE
USERBS_210 ONLINE
TEMPTBS_210 ONLINE
ORCLTBS1_234 ONLINE
USERBS_234 ONLINE
TEMPTBS_234 ONLINE
TABLESPACE_NAME STATUS
------------------------------ ---------
ORCLTBS1_222 ONLINE
USERBS_222 ONLINE
TEMPTBS_222 ONLINE
ORCLTBS1_226 ONLINE
USERBS_226 ONLINE
TEMPTBS_226 ONLINE
ORCLTBS1_235 ONLINE
USERBS_235 ONLINE
TEMPTBS_235 ONLINE
PRODUCT_210 ONLINE
已选择21行。
--更改表空间名
SQL> alter tablespace userbs_210 rename to usertbs_210;
表空间已更改。
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
ORCLTBSL_210 ONLINE
USERTBS_210 ONLINE
TEMPTBS_210 ONLINE
ORCLTBS1_234 ONLINE
USERBS_234 ONLINE
TEMPTBS_234 ONLINE
TABLESPACE_NAME STATUS
------------------------------ ---------
ORCLTBS1_222 ONLINE
USERBS_222 ONLINE
TEMPTBS_222 ONLINE
ORCLTBS1_226 ONLINE
USERBS_226 ONLINE
TEMPTBS_226 ONLINE
ORCLTBS1_235 ONLINE
USERBS_235 ONLINE
TEMPTBS_235 ONLINE
PRODUCT_210 ONLINE
已选择21行。
SQL> create table stud_range_210
2 (studID char(10) primary key,
3 studName Varchar2(20) not null,
4 sex char(2),
5 startDate date,
6 depart varchar2(30)
7 )
8 partition by range(startDate)
9 (partition p1 values less than
10 (to_date('2011-8-1','yyyy-mm-dd'))
11 tablespace orcltbsl_210,
12 partition p2 values less than
13 (to_date('2013-8-1','yyyy-mm-dd'))
14 tablespace usertbs_210,
15 partition p3 values less than(maxvalue)
16 tablespace users
17 );
表已创建。
SQL> create table stud_list_210
2 (studID char primary key,
3 studName Varchar2(20) not null,
4 sex char(2),
5 startDate date,
6 depart Varchar2(30)
7 )
8 partition by list(depart)
9 (partition p1 values('计算机系') tablespace usertbs_210,
10 partition p2 values('管理系') tablespace users
11 );
表已创建。
SQL> create table stud_hash_210
2 (studID char primary key,
3 studName Varchar2(20) not null,
4 sex char(2),
5 startDate date,
6 depart varchar2(30)
7 )
8 partition by hash(studID)
9 (partition p1 tablespace usertbs_210,
10 partition p2 tablespace orcltbsl_210
11 );
表已创建。
SQL> select table_name,partitioning_type from user_part_tables
2 where table_name like'STUD_%';
TABLE_NAME PARTITION
------------------------------ ---------
STUD_HASH_210 HASH
STUD_LIST_210 LIST
STUD_RANGE_210 RANGE
SQL> select partition_name, tablespace_name from user_tab_partitions
2 where table_name like 'STUD_HASH%';
PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------
P1 USERTBS_210
P2 ORCLTBSL_210
SQL> create user stud identified by oracle11g;
用户已创建。
SQL> grant dba to stud;
授权成功。
SQL>
SQL*Plus: Release 11.2.0.1.0 Production on 星期五 10月 9 15:15:49 2020
Copyright (c) 1982, 2010, Oracle. All rights reserved.
请输入用户名: stud@study
输入口令:
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @D:\oracle\test\createTable.txt
表已创建。
表已创建。
表已创建。
SQL> @D:\oracle\test\insert_OrderDetails.txt
已创建 1 行。
已创建 1 行。
SQL> @D:\oracle\test\insert_Orders.txt
已创建 1 行。
SQL> @D:\oracle\test\insert_Products.txt
已创建 1 行。
SQL> set autotrace on;
SQL> create index ind_prod_cated
2 on products(categoryid)
3 tablespace users;
索引已创建。
SQL> select productid,productName,unitPrice
2 from products where categoryid='2';
PRODUCTID
----------
PRODUCTNAME
--------------------------------------------------------------------------------
UNITPRICE
----------
3
Aniseed Syrup
10
4
SQL> create unique index ind_unq_prodname
2 on products(productName)
3 tablespace users;
索引已创建。
SQL> create bitmap index ind_btm_country
2 on orders(ShipCountry);
索引已创建。
SQL> create index ind_fun_oDate
2 on orders (extract(year from orderDate));
索引已创建。
SQL>