chapter8: Managing Schema Objects

Chapter 8: Managing Schema Objects

Purpose

A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are logical structures created by users to contain, or reference, their data. Schema objects include structures like tables, views, and indexes. You can create and manipulate schema objects using Oracle Enterprise Manager.

Topics

This following topics are discussed in this chapter:

bullet.gifAccessing Schema Objects
bullet.gifManaging Tables
bullet.gifManaging Indexes
bullet.gifManaging Views
bullet.gifManaging Database Resident Program Units
bullet.gifLoading Data into Tables

view_image.gif Move your mouse over this icon to show all screenshots. You can also move your mouse over each individual icon to see only the screenshot associated with it.

Accessing Schema Objects

Back to Topic List

Follow the steps below to access schema objects using Enterprise Manager:

1.

Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS username and password.

Click Login.

2.

Click Administration and select the Tables link.

Move your mouse over this icon to see the image

3.

Select the flashlight icon to select a particular schema.

Move your mouse over this icon to see the image

4.

Select HR and click Select.

Move your mouse over this icon to see the image

5.

Enter emp in the Object Name field and click Go.

Move your mouse over this icon to see the image

6.

The objects that match your search criteria are displayed.

Move your mouse over this icon to see the image

Back to Topic List

Tables are the basic unit of data storage in an Oracle database. They hold all user-accessible data. Each table has columns and rows. In this section, you will perform the following tasks:

bullet.gifViewing the Attributes of a Table
bullet.gifViewing the Contents of a Table
bullet.gifCreating a New Table
bullet.gifModifying a Table
bullet.gifDropping a Table
Viewing the Attributes of a Table

Back to Topic List

Follow the steps below to view the attributes of the HR.EMPLOYEES table:

1.

Select the EMPLOYEES table and click View.

Move your mouse over this icon to see the image

2.

The Table View page appears displaying the attributes of the table including columns, constraints, and storage options.

Move your mouse over this icon to see the image

Click the Tables link to return to the Tables property page.

Viewing the Contents of a Table

Back to Topic List

Perform the steps listed below to view the contents of the HR.EMPLOYEES table:

1.

Select the EMPLOYEES table and select View Data from the Actions drop-down menu. Click Go.

Move your mouse over this icon to see the image

2.

The View Data For Table page appears showing the row data in the Results section.

Move your mouse over this icon to see the image

Creating a New Table

Back to Topic List

In this section you will create three new tables for your database: EMPLOYEES, CUSTOMERS, and ORDERS.

1.

Click Create on the Tables property page.

Move your mouse over this icon to see the image

2.

The Create Table: Table Organization page appears. Select Standard, Heap Organized and click Continue.

Move your mouse over this icon to see the image

3.

The Create Table page appears. Enter employees in the Name field. Enter fsowner in the Schema field. Enter fsdata in the Tablespace field. Define the columns as follows and click Add 5 Table Columns.

EMPLOYEE_ID NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(25)
EMAIL_ADDRESS VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)

Move your mouse over this icon to see the image

4.

Enter the remaining columns as follows:

HIRE_DATE DATE
JOB_ID VARCHAR2(10)
SALARY NUMBER(8)
MANAGER_ID NUMBER(6)

Click Constraints.

Move your mouse over this icon to see the image

5.

The Constraints page appears. Select Primary from the drop-down menu and click Add.

Move your mouse over this icon to see the image

6.

The Add Primary Constraint page appears. Enter emp_id_pk in the Name field. Select EMPLOYEE_ID in the Available Columns list. Click Move to select it. Click OK.

Move your mouse over this icon to see the image

7.

The Create Table page appears. Click OK.

Move your mouse over this icon to see the image

8.

The Table page appears with an Update message indicating your table has been created.

Move your mouse over this icon to see the image

9.

Repeat steps 2 through 8 to create the CUSTOMERS and ORDERS tables in the FSOWNER schema as defined below.

CUSTOMERS
ColumnTypePK?
CUSTOMER_IDNUMBER(6)
Y
CUST_FIRST_NAMEVARCHAR2(20)
CUST_LAST_NAMEVARCHAR2(20)
STREET_ADDRESSVARCHAR2(40)
CITYVARCHAR2(30)
STATEVARCHAR2(10)
POSTAL_CODEVARCHAR2(10)
PHONE_NUMBERVARCHAR2(20)

ORDERS
ColumnTypePK?
ORDER_IDNUMBER(12)
Y
ORDER_DATEDATE
ORDER_MODEVARCHAR2(8)
CUSTOMER_IDNUMBER(6)
DELIVERY_MODEVARCHAR2(8)
ORDER_STATUSNUMBER(2)
SALES_CLERK_IDNUMBER(6)
ORDER_TOTALNUMBER(8,2)
Modifying a Table

Back to Topic List

You can use Enterprise Manager to modify tables, such as adding and deleting columns or adding constraints. In this section you will add a constraint to the EMPLOYEES table you created. You will ensure that the EMAIL_ADDRESS column contains a value by adding a NOT NULL constraint.

Follow the steps below to add a NOT NULL constraint to your EMPLOYEES table:

1.

Select the EMPLOYEES table and click Edit.

Move your mouse over this icon to see the image

2.

Check the Not NULL column for the EMAIL_ADDRESS column. Click Apply.

Move your mouse over this icon to see the image

3.

The Edit Table page is displayed with a message confirming your update.

Move your mouse over this icon to see the image

Dropping a Table

Back to Topic List

You can drop (delete) a table by using Enterprise Manager as follows. For the purposes of this exercise, you will create a new table and then drop the table.


1.

Click the Tables link in the Schema section on the Administration page to access the Schema objects property page. Select Table in the Object Type drop-down menu. Enter HR in the Schema Name field and JOBS in the Object Name field. Click Go.

Move your mouse over this icon to see the image

2.

Select Create Like from the Actions drop-down menu. Click Go.

Move your mouse over this icon to see the image

3.

The Create Table page appears. Enter JOBS_HIST in the Name field. Deselect Not Null for the JOB_ID and JOB_TITLE columns. Click Constraints.

Move your mouse over this icon to see the image

4.

The Constraints page appears. Delete the constraints on the table by selecting each and clicking Delete. They are not needed for this exercise. Click General to return to the General page.

Move your mouse over this icon to see the image

5.

Click OK to create the JOBS_HIST table.

Move your mouse over this icon to see the image

6.

A message is displayed indicating that the table has been created.

Move your mouse over this icon to see the image

7.

Enter JOBS_HIST in the Object Name field and click Go.

Move your mouse over this icon to see the image

8.

The Tables page is displayed with the JOBS_HIST table in the Results section. Click Delete to the delete the JOBS_HIST table.

Move your mouse over this icon to see the image

9.

Click Yes to confirm the deletion of the table.

Move your mouse over this icon to see the image

10.

A message is displayed indicating the table has been deleted. Click Go to attempt to retrieve the table.

Move your mouse over this icon to see the image

11.

No object found is displayed in the results section indicating your table has been dropped (deleted).

Move your mouse over this icon to see the image

Back to Topic List

Indexes are optional structures associated with tables and can be used to improve query performance. An index provides a quick access path to table data. Indexes can be created on one or more columns of a table. After an index is created, it is automatically maintained and used by the Oracle Database server. Changes to a table’s data or structure are automatically incorporated into all relevant indexes with complete transparency to the user.

In this section, you will perform the following tasks:

bullet.gifViewing the Attributes of an Index
bullet.gifCreating a New Index
Viewing the Attributes of an Index

Back to Topic List

Perform the steps listed below to view the attributes of an index in your FSOWNER schema:

1.

Click the Indexes link in the Schema section on the Administration page to access the Indexes property page.

Move your mouse over this icon to see the image

2.

The Indexes page appears. Enter FSOWNER in the Schema Name field and click Go.

Move your mouse over this icon to see the image

3.

The indexes created when you defined primary keys are displayed. Select the EMP_ID_PK index defined on the EMPLOYEES table by clicking the index name link.

Move your mouse over this icon to see the image

4.

The EMP_ID_PK index for the EMPLOYEES table is displayed.

Move your mouse over this icon to see the image

Select the Indexes link to return to the Indexes property page.

Creating a New Index

Back to Topic List

Create an index on the CUSTOMER_ID column in the ORDERS table so that you can quickly access all orders for a specified customer. The index should be stored in the FSINDEX tablespace.

Perform the steps listed below to create the ORD_CUSTID_IDX index:

1.

Select Tables for the Object Type. Enter FSOWNER in the Schema field and click Go

Move your mouse over this icon to see the image

2.

.The Tables page appears. Select the ORDERS table and select Create Index from the Actions drop-down menu. Click Go.

Move your mouse over this icon to see the image

3.

The Create Index page appears. Enter ORD_CUSTID_INDX in the Name field. Enter fsindex in the Tablespace field. Select Standard B-tree as the index type. Select the CUSTOMER_ID column by entering 1 in the Order column. Accept ASC as the Sorting Order. Click OK to create the index.

Move your mouse over this icon to see the image

Back to Topic List

Views are customized presentations of data in one or more tables or other views. They can be thought of as stored queries. Views do not actually contain data, but instead
they derive their data from the tables upon which they are based. These tables are referred to as the base tables of the view. Like tables, views can be queried, updated, inserted into, and deleted from, with some restrictions. All operations performed on a view actually affect the base tables of the view. Views provide an additional level of security by restricting access to a predetermined set of rows and columns of a table. They also hide data complexity and store complex queries. In this section, you will perform the following tasks:

bullet.gifAccessing Views
bullet.gifCreating a New View
Accessing Views

Back to Topic List

Perform the steps listed below to access views:

1.

Select Views in the Schema region of the Administration page. Enter HR in the Schema Name field and click Go.

Move your mouse over this icon to see the image

2.

The views defined on tables in the HR schema are displayed. Select the EMP_DETAILS_VIEW and click View to view its definition.

Move your mouse over this icon to see the image

3.

The View page is displayed showing the definition of the view.

Move your mouse over this icon to see the image

Select the Views link.

Creating a New View

Back to Topic List

Perform the steps listed below to create a new view:

1.

Click Create on the Views property page.

Move your mouse over this icon to see the image

2.

Enter the following information and click OK.

View name: CLERK10_ORDS
Schema: FSOWNER
Query text:

SELECT order_id, customer_id, order_total FROM orders WHERE sales_clerk_id = 10

Move your mouse over this icon to see the image

3.

The Views page is displayed confirming the creation of your view.

Move your mouse over this icon to see the image

Select the Database link.

Back to Topic List

You can use Enterprise Manager to manage database resident program units such as PL/SQL packages, procedures, triggers, and functions and Java sources and classes. The actions include creating and compiling the database resident program units, creating synonyms for the database resident program units, granting privileges to use the database resident program units, and showing dependencies for the database resident program units.

1.

Click the Procedures link in the Schema section on the Administration page.

Move your mouse over this icon to see the image

2.

Enter hr in the Schema field click Go.

Move your mouse over this icon to see the image

3.

Select the ADD_JOB_HISTORY procedure. Select Grant Privileges from the drop-down menu and click Go.

Move your mouse over this icon to see the image

4.

Select EXECUTE as the privilege and FSOWNER as the user. Click OK.

Move your mouse over this icon to see the image

Loading Data Into Tables

Back to Topic List

You can use Enterprise Manager to load data into tables in batch. Batch loading is useful when you have a lot of data. You can load data from operating system files or
from other databases. You can also export data into files. One method of loading is to use control (.ctl) and data (.dat) files. These files are formatted as standard SQL*Loader files. SQL*Loader is a utility that you can use to load data from external files into tables of an Oracle database.

In this section you will load customer information into your FSOWNER.CUSTOMERS table using the load_cust.ctl file. Create a directory named $HOME/labs. Download the load_cust.zip file and unzip the load_cust.ctl and load_cust.dat files into $HOME/labs for use in this section.

1.

Click the Load Data From File link in the Utilities section on the Maintenance page.

Move your mouse over this icon to see the image

2.

The Load Data: Control File page appears. Enter the full path of your control file on the database server machine. Also enter the username and password for the host machine. Click Next.

Move your mouse over this icon to see the image

3.

The Load Data: Data File page appears. Select The data file is specified in the control file. Click Next.

Move your mouse over this icon to see the image

4.

The Load Data: Load Method page appears. Accept the default of Conventional Path as the loading method. Click Next.

Move your mouse over this icon to see the image

5.

The Load Data: Options page appears. Select Generate log file in the Optional Files region. You can accept the default file name and path or enter a different one. Click Next.

Move your mouse over this icon to see the image

6.

The Load Data: Schedule page appears. Enter a name in the Job Name field and description in the Description field. Select Immediately to run the job now. Click Next.

Move your mouse over this icon to see the image

7.

The Load Data: Review page appears. Review your file names and loading methods. If you want to change something, you can click on the Back button. Otherwise, click Submit Job to start the loading.

Move your mouse over this icon to see the image

8.

The Status page appears with a message indicating Load Data Submit Successful. Click on View
Job
to view the job summary.

Move your mouse over this icon to see the image

9.

This summary page should indicate that the job has succeeded. If not, you can view the log file by clicking on your job under the Logs heading or by viewing the log file directly.

Move your mouse over this icon to see the image

10.

You can confirm the data load by navigating to the Tables page, selecting the table, and selecting View Data as the action. Click Go.

Move your mouse over this icon to see the image

11.

The rows you loaded are displayed on the View Data for Table: FSOWNER.CUSTOMERS page. Click OK to return to the Tables property page.

Move your mouse over this icon to see the image

view_image.gif Move your mouse over this icon to hide all screenshot

基于粒子群优化算法的p-Hub选址优化(Matlab代码实现)内容概要:本文介绍了基于粒子群优化算法(PSO)的p-Hub选址优化问题的研究与实现,重点利用Matlab进行算法编程和仿真。p-Hub选址是物流与交通网络中的关键问题,旨在通过确定最优的枢纽节点位置和非枢纽节点的分配方式,最小化网络总成本。文章详细阐述了粒子群算法的基本原理及其在解决组合优化问题中的适应性改进,结合p-Hub中转网络的特点构建数学模型,并通过Matlab代码实现算法流程,包括初始化、适应度计算、粒子更新与收敛判断等环节。同时可能涉及对算法参数设置、收敛性能及不同规模案例的仿真结果分析,以验证方法的有效性和鲁棒性。; 适合人群:具备一定Matlab编程基础和优化算法理论知识的高校研究生、科研人员及从事物流网络规划、交通系统设计等相关领域的工程技术人员。; 使用场景及目标:①解决物流、航空、通信等网络中的枢纽选址与路径优化问题;②学习并掌握粒子群算法在复杂组合优化问题中的建模与实现方法;③为相关科研项目或实际工程应用提供算法支持与代码参考。; 阅读建议:建议读者结合Matlab代码逐段理解算法实现逻辑,重点关注目标函数建模、粒子编码方式及约束处理策略,并尝试调整参数或拓展模型以加深对算法性能的理解。
内容概要:本文全面介绍了C#全栈开发的学习路径与资源体系,涵盖从基础语法到企业级实战的完整知识链条。内容包括C#官方交互式教程、开发环境搭建(Visual Studio、VS Code、Mono等),以及针对不同应用场景(如控制台、桌面、Web后端、跨平台、游戏、AI)的进阶学习指南。通过多个实战案例——如Windows Forms记事本、WPF学生管理系统、.NET MAUI跨平台动物图鉴、ASP.NET Core实时聊天系统及Unity 3D游戏项目——帮助开发者掌握核心技术栈与架构设计。同时列举了Stack Overflow、Power BI、王者荣耀后端等企业级应用案例,展示C#在高性能场景下的实际运用,并提供了高星开源项目(如SignalR、AutoMapper、Dapper)、生态工具链及一站式学习资源包,助力系统化学习与工程实践。; 适合人群:具备一定编程基础,工作1-3年的研发人员,尤其是希望转型全栈或深耕C#技术栈的开发者; 使用场景及目标:①系统掌握C#在不同领域的应用技术栈;②通过真实项目理解分层架构、MVVM、实时通信、异步处理等核心设计思想;③对接企业级开发标准,提升工程能力和实战水平; 阅读建议:此资源以开发简化版Spring学习其原理和内核,不仅是代码编写实现也更注重内容上的需求分析和方案设计,所以在学习的过程要结合这些内容一起来实践,并调试对应的代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值