oracle心得1--oracle簡(jiǎn)介
Jun 07, 2016 pm 03:38 PM1. Oracle 簡(jiǎn)介 Oracle是殷墟出土的甲骨文(oracle bone inscriptions)的英文翻譯的第一個(gè)單詞 。 Oracle 公司是全球最大的信息管理軟件及服務(wù)供應(yīng)商,成立于1977 年,總部位于美國(guó)加州 Redwood shore;Oracle公司因其復(fù)雜的關(guān)系數(shù)據(jù)庫(kù)產(chǎn)品而聞名。Oracle的關(guān)
1. Oracle 簡(jiǎn)介
Oracle是殷墟出土的甲骨文(oracle bone inscriptions)的英文翻譯的第一個(gè)單詞。Oracle公司是全球最大的信息管理軟件及服務(wù)供應(yīng)商,成立于1977年,總部位于美國(guó)加州 Redwood shore;Oracle公司因其復(fù)雜的關(guān)系數(shù)據(jù)庫(kù)產(chǎn)品而聞名。Oracle的關(guān)系數(shù)據(jù)庫(kù)是世界第一個(gè)支持SQL語(yǔ)言的數(shù)據(jù)庫(kù)
2. Oracle 數(shù)據(jù)庫(kù)和 Oracle 實(shí)例
Oracle 服務(wù)器由兩大部分組成, Oracle 數(shù)據(jù)庫(kù)和 Oracle 實(shí)例。
Oracle 數(shù)據(jù)庫(kù): 位于硬盤(pán)上實(shí)際存放數(shù)據(jù)的文件, 這些文件組織在一起, 成為一個(gè)邏輯整體, 即為 Oracle 數(shù)據(jù)庫(kù). 因此在 Oracle 看來(lái), “數(shù)據(jù)庫(kù)” 是指硬盤(pán)上文件的邏輯集合, 必須要與內(nèi)存里實(shí)例合作, 才能對(duì)外提供數(shù)據(jù)管理服務(wù).
Oracle 實(shí)例: 位于物理內(nèi)存里的數(shù)據(jù)結(jié)構(gòu). 它由一個(gè)共享的內(nèi)存池和多個(gè)后臺(tái)進(jìn)程所組成, 共享的內(nèi)存池可以被所有進(jìn)程訪(fǎng)問(wèn). 用戶(hù)如果要存取數(shù)據(jù)庫(kù)(也就是硬盤(pán)上的文件) 里的數(shù)據(jù), 必須通過(guò)實(shí)例才能實(shí)現(xiàn), 不能直接讀取硬盤(pán)上的文件.
區(qū)別: 實(shí)例可以操作數(shù)據(jù)庫(kù); 在任何時(shí)刻一個(gè)實(shí)例只能與一個(gè)數(shù)據(jù)庫(kù)關(guān)聯(lián); 大多數(shù)情況下, 一個(gè)數(shù)據(jù)庫(kù)上只有一個(gè)實(shí)例對(duì)其進(jìn)行操作.
3. 注意
SQL 語(yǔ)言大小寫(xiě)不敏感;但where或having條件引號(hào)中的單詞大小寫(xiě)敏感;SQL 可以寫(xiě)在一行或者多行;關(guān)鍵字不能被縮寫(xiě)也不能分行;各子句一般要分行寫(xiě)。;使用縮進(jìn)提高語(yǔ)句的可讀性。
乘除的優(yōu)先級(jí)高于加減;同一優(yōu)先級(jí)運(yùn)算符從左向右執(zhí)行。括號(hào)內(nèi)的運(yùn)算先執(zhí)行; 括號(hào)決定一切!
空值是無(wú)效的,未指定的,未知的或不可預(yù)知的值;空值不是空格或者0
4. 案例知識(shí)點(diǎn)分析
列的別名:
重命名一個(gè)列,便于計(jì)算。緊跟列名,也可以在列名和別名之間加入關(guān)鍵字‘AS’,別名使用雙引號(hào),以便在別名中包含空格或特殊的字符并區(qū)分大小寫(xiě)。
連接符:
把列與列,列與字符連接在一起。用 ‘||’表示??梢杂脕?lái)‘合成’列。
? 例子:
select deptno||dname from dept;
?
DEPTNO||DNAME????????????????????????????????????????????????????????????
------------------------------------------------------??????????????????
10ACCOUNTING?????????????????????????????????????????????????????????????
20RESEARCH???????????????????????????????????????????????????????????????
30SALES??????????????????????????????????????????????????????????????????
40OPERATIONS
?
字符串和日期:
字符串可以是 SELECT 列表中的一個(gè)字符,數(shù)字,日期。日期和字符只能在單引號(hào)中出現(xiàn)。每當(dāng)返回一行時(shí),字符串被輸出一次。字符和日期要包含在單引號(hào)中。
字符大小寫(xiě)敏感,日期格式敏感。默認(rèn)的日期格式是 DD-MON-RR。
行的去重復(fù):
? ???默認(rèn)情況下,查詢(xún)會(huì)返回全部行,包括重復(fù)行。在 SELECT 子句中使用關(guān)鍵字 ‘DISTINCT’ 刪除重復(fù)行。
例子:select distinct(job) from emp;
5. SQL 和 SQL*Plus
使用SQL*Plus可以:
描述表結(jié)構(gòu);編輯 SQL 語(yǔ)句;執(zhí)行 SQL語(yǔ)句。 將 SQL 保存在文件中并將SQL語(yǔ)句執(zhí)行結(jié)果保存在文件中。在保存的文件中執(zhí)行語(yǔ)句。將文本文件裝入 SQL*Plus編輯窗口。
6其它比較運(yùn)算
使用 LIKE 運(yùn)算選擇類(lèi)似的值;
選擇條件可以包含字符或數(shù)字:% 代表零個(gè)或多個(gè)字符(任意個(gè)字符);_ 代表一個(gè)字符;‘%’和‘-’可以同時(shí)使用;可以使用 ESCAPE 標(biāo)識(shí)符 選擇‘%’和 ‘_’ 符號(hào);回避特殊符號(hào)的:使用轉(zhuǎn)義符。例如:將[%]轉(zhuǎn)為[\%]、[_]轉(zhuǎn)為[\_],然后再加上[ESCAPE ‘\’] 即可;使用 IS (NOT) NULL 判斷空值。
例子:
select * from emp where sal between 1000 and 2000; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30 7654 MARTIN SALESMAN 7698 28-9月 -81 1250 1400 30 7844 TURNER SALESMAN 7698 08-9月 -81 1500 0 30 7876 ADAMS CLERK 7788 23-5月 -87 1100 20 7934 MILLER CLERK 7782 23-1月 -82 1300 10 select * from emp where sal in(1250,1600); EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30 7654 MARTIN SALESMAN 7698 28-9月 -81 1250 1400 30 select * from emp where comm is null; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7369 SMITH CLERK 7902 17-12月-80 800 20 7566 JONES MANAGER 7839 02-4月 -81 2975 20 7698 BLAKE MANAGER 7839 01-5月 -81 2850 30 select * from emp where comm is not null; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30 select * from emp where ename like 'A%'; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7876 ADAMS CLERK 7788 23-5月 -87 1100 20 select * from emp where ename like '_L%'; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ----- -------------- ----- ------ ------ 7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30 7698 BLAKE MANAGER 7839 01-5月 -81 2850 30 7782 CLARK MANAGER 7839 09-6月 -81 2450 10 select job_id from jobs where job_id like 'ST\_%' escape '\'; JOB_ID ---------- ST_CLERK ST_MAN
?
7. 優(yōu)先級(jí)
可以使用括號(hào)改變優(yōu)先級(jí)順序
8. ORDER BY子句
使用 ORDER BY 子句排序
ASC(ascend): 升序
DESC(descend): 降序
ORDER BY 子句在SELECT語(yǔ)句的結(jié)尾。
可以使用不在SELECT 列表中的列排序
例子:
?
<span>select empno,d.deptno,ename,dname,sal from emp e,dept d where e.deptno=d.deptno order by sal asc,d.deptno desc; EMPNO DEPTNO ENAME DNAME SAL ---------- ------ ---------- -------------- ----- 7369 20 SMITH RESEARCH 800 7900 30 JAMES SALES 950 7876 20 ADAMS RESEARCH 1100 7521 30 WARD SALES 1250 7654 30 MARTIN SALES 1250 7934 10 MILLER ACCOUNTING 1300 7844 30 TURNER SALES 1500 7499 30 ALLEN SALES 1600 7782 10 CLARK ACCOUNTING 2450 7698 30 BLAKE SALES 2850 7566 20 JONES RESEARCH 2975 EMPNO DEPTNO ENAME DNAME SAL ---------- ------ ---------- -------------- ----- 7788 20 SCOTT RESEARCH 3000 7902 20 FORD RESEARCH 3000 7839 10 KING ACCOUNTING 5000 </span>
?

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

MongoDB is suitable for handling large-scale unstructured data, and Oracle is suitable for enterprise-level applications that require transaction consistency. 1.MongoDB provides flexibility and high performance, suitable for processing user behavior data. 2. Oracle is known for its stability and powerful functions and is suitable for financial systems. 3.MongoDB uses document models, and Oracle uses relational models. 4.MongoDB is suitable for social media applications, while Oracle is suitable for enterprise-level applications.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

MongoDB is suitable for unstructured data and high scalability requirements, while Oracle is suitable for scenarios that require strict data consistency. 1.MongoDB flexibly stores data in different structures, suitable for social media and the Internet of Things. 2. Oracle structured data model ensures data integrity and is suitable for financial transactions. 3.MongoDB scales horizontally through shards, and Oracle scales vertically through RAC. 4.MongoDB has low maintenance costs, while Oracle has high maintenance costs but is fully supported.

Configuring WebLogic database connection on a CentOS system requires the following steps: JDK installation and environment configuration: Make sure that the server has installed a JDK that is compatible with the WebLogic version (for example, WebLogic14.1.1 usually requires JDK8). Correctly set JAVA_HOME, CLASSPATH and PATH environment variables. WebLogic installation and decompression: Download the WebLogic installation package for CentOS system from the official Oracle website and unzip it to the specified directory. WebLogic user and directory creation: Create a dedicated WebLogic user account and set a security password
