Oracle中常见的数据库对象--视图
数据库对象—视图: 一、视图的定义:从表中抽出的逻辑上相关的数据集合 a) 视图是一种虚表 b) 视图建立在已有表
数据库对象—视图:
一、视图的定义:从表中抽出的逻辑上相关的数据集合
a) 视图是一种虚表
b) 视图建立在已有表基础上,视图依赖已建立的这些表称为基表
c) 向视图提供数据内容的语句为SELECT语句,,可以将视图理解为存储起来的SElECT语句
d) 视图向用户提供基表数据的另一种表示形式
二、为什么要使用视图
a) 控制数据访问:提供了一种安全机制,通过视图显示数据时,屏蔽用户不应该知道的数据.
b) 简化查询:select语句构造了一个复杂的查询语句,每次使用必须都得调用它
c) 避免重复访问相同的数据
三、创建视图:
a) 在CREATE VIEW语句中嵌入子查询
i. Create [OR REPLACE] [FORCE | NOFORCE] VIEW view [(alias [,alias]…)]
AS subquerytion
[with check option [CONSTRAINT constraint ]]
[with read only [CONSTRAINT constraint]]
b) 子查询可以是复杂的SELECT语句
i. CREATE VIEW empvu
AS select employee_id,last_name,salary
FROM employees
WHERE department_ed=80;
c) 描述视图结构:
i. Describe empvu;
d) 创建视图时在子查询中给列定义别名
i. SQL> create view usersview as select username name,password pass from users;
ii. //查询视图
SQL> select * from usersview;
e) 使用CREATE OR REPLACE VIEW 子句修改视图
i. SQL> create or replace view usersview as(select * from users);
f) 创建带有函数,groupby子句视图
i. SQL> create or replace view gde as ( select deptno,count(*) cou from emp group by deptno);
g) 创建连接视图 带有函数 group by子句 order by 子句
i. SQL> create view gdeo as select e.deptno,count(*) cou from emp e inner join dept d on e.deptno=d.deptno group by e.deptno order by e.deptno;
四、 视图中使用DML的规定
a) 可以在简单视图中执行DML操作
b) 当时图定义中包含以下元素之一是不能使用delete:
i. 组函数
ii. GROUP BY 子句
iii. DISTINCT 关键字
iv. ROWNUM 伪列
c) 当视图定义中包含以下元素之一时不能使用update :
i. 组函数
ii. GROUP BY子句
iii. DISTINCT 关键字
iv. ROWNUM 伪列
v. 列的定义为表达式
d) 可以使用 WITH READ ONLY 选项屏蔽对视图的DML 操作
d)任何 DML 操作都会返回一个Oracle server 错误
五、 删除视图
a) Drop view 视图名;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.
