设为首页 收藏本站
查看: 1037|回复: 0

[经验分享] Oracle数据库操作总结之一

[复制链接]

尚未签到

发表于 2016-7-30 21:50:37 | 显示全部楼层 |阅读模式
  /****************by garcon1986***************/
  
  RDBMS(Relational Data Base Management System)
  
ER图(Entity Relationship)
  
  Primary key主键
Foreign key外键
  
  Data Definition Language (DDL) statements are used to define the database structure or schema.
数据定义语言,用于管理数据库结构
* CREATE - to create objects in the database
* ALTER - alters the structure of the database
* DROP - delete objects from the database
* TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
* COMMENT - add comments to the data dictionary
* RENAME - rename an object
  
Data Manipulation Language (DML) statements are used for managing data within schema objects.
数据操作语言,用于管理数据库对象的数据。
* SELECT - retrieve data from the a database
* INSERT - insert data into a table
* UPDATE - updates existing data within a table
* DELETE - deletes all records from a table, the space for the records remain
* MERGE - UPSERT operation (insert or update)
* CALL - call a PL/SQL or Java subprogram
* EXPLAIN PLAN - explain access path to data
* LOCK TABLE - control concurrency
  
Data Control Language (DCL) statements.
数据控制语言
* GRANT - gives user's access privileges to database
* REVOKE - withdraw access privileges given with the GRANT command
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
  
事务控制语言
* COMMIT - save work done
* SAVEPOINT - identify a point in a transaction to which you can later roll back
* ROLLBACK - restore database to original since the last COMMIT
* SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
  
  SQL vs. iSQL*Plus:
iSQL*Plus是一个browser环境,Oracle特有。
通过http://xxx:5560/isqlplus/访问。
Where:
SELECT last_name, salary
FROM employees
WHERE salary <= 3000 ;
SELECT last_name, salary
FROM employees
WHERE salary BETWEEN 2500 AND 3500 ;
SELECT employee_id, last_name, salary, manager_id
FROM employees
WHERE manager_id IN (100, 101, 201) ;
SELECT first_name
FROM employees
WHERE first_name LIKE 'S%' ; //%代表了0到多个字符
SELECT first_name
FROM employees
WHERE first_name LIKE '_o%' ; //_代表了1个字符
SELECT employee_id, job_id
FROM employees
WHERE job_id LIKE 'SA/_R%' ESCAPE '/'; // Escape符/
SELECT last_name, manager_id
FROM employees
WHERE manager_id IS NULL ;
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date ; //默认ASC升序,DESC降序
SELECT employee_id, last_name, salary, department_id
FROM employees
WHERE employee_id = &employee_num ; //使用&来提示输入值
SELECT employee_id, last_name, job_id, &column_name
FROM employees
WHERE &condition
ORDER BY &order_column ;
SELECT employee_id, last_name, job_id, &&column_name
FROM employees
ORDER BY &column_name ; //使用&&可以重用变量值。
DEFINE employee_num = 200 //定义变量
UNDEFINE employee_num //删除变量
  
字符函数:
lower('SQL Course') -> sql course
upper('SQL Course') -> SQL COURSE
initcap('SQL Course') -> Sql Course
concat('hello','world') -> helloworld
substr('helloworld',1,5) -> hello
length('helloworld') -> 10
instr('helloworld') -> 6
lpad(salary, 10, '*') -> *****24000
rpad(salary, 10 , '*') -> 24000*****
replace('java and c', 'j', 'c') -> cava and c
trim('h' from 'hellworld') -> elloworld
  
数字函数:
round(45.937) -> 45.97
trunc(45.937) -> 45.93
mod(100, 30) -> 10
select round(45.937, 2)
from dual; //dual是一个虚拟表。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-251413-1-1.html 上篇帖子: 关于Oracle去除重复的问题 下篇帖子: oracle查询语句学习笔记以及语句
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表