当前位置:网站首页>Oracle database knowledge points that cannot be learned (II)
Oracle database knowledge points that cannot be learned (II)
2022-07-04 00:41:00 【zhulin1028】
SQL Query and SQL function
1.SQl Supported commands :
Data definition language (DDL):create,alter,drop
Data manipulation language (DML):insert,delete,update,select
Data control language (DCL):grant,revoke
Transaction control language (TCL):commit,savepoint,rollback
2.Oracle data type
character , The number , date ,RAW,LOB
Character
char:1-2000 Fixed length characters of bytes
varchar2:1-4000 Variable length characters of bytes
long:2GB Variable length character of
Be careful : At most one column in a table can be long type
Long Columns cannot define unique constraints or primary key constraints
long Cannot create index on column
Procedures or stored procedures are not acceptable long Parameters of type .
Numerical type
number: Highest accuracy 38 position
Date time type
date: Accurate to ss
timestamp: The second value is accurate to the decimal point 6 position
function sysdate,systimestamp Return the current system date , Time and time zone .
Change the display of time
alter session set nls_date_language=’american’;
alter session set nls_date_format=’yyyy-mm-dd’;Oracle Pseudo columns in , Like a table column , But it is not stored in the table , Pseudo columns can be queried , But you can't insert 、 Update and modify their values , Common pseudo columns :rowid and rownum.
rowid: The storage address of the row in the table , It can uniquely identify a row in the database , You can use this column to quickly locate rows in the table .
rownum: The query returns the sequence number of the row in the result set , You can use it to limit the number of rows returned by the query .
3. Data definition language
Commands for manipulating tables
create table
alter table
truncate table
drop table
The command to modify the table
alter table stu_table rename to stu_tbl;-- Modify the name of the table
alter table stu_tbl rename column stu_sex to sex;-- Change column names
alter table stu_tbl add (stu_age number);-- Add new column
alter table stu_tbl drop(sex);-- Delete column
alter table stu_tbl modify(stu_sex varchar2(2));-- Change the data type of the column
alter table stu_tbl add constraint pk_stu_tbl primary key(id);-- Adding constraints 4. Data manipulation language
select,update,delete,insert
Create a table from an existing table
create table stu_tbl_log as select id,stu_name,stu_age from stu_tbl;-- Select a row without repetition
select distinct stu_name from stu_tbl;-- Insert records from other tables
insert into stu_tbl_log select id,stu_name,stu_age from stu_tbl;5. Data control language
grant,revoke
6. Transaction control language
commit,savepoint,rollback
7.SQL The operator
arithmetic operator :+-*/
Comparison operator :=,!=,<>,>,<,>=,<=,between-and,in,like,is null etc.
Logical operators :and,or,not
Set operators :union,union all,intersect,minus
Join operators :||
Example :
select (3+2)/2 from dual;-- arithmetic operator , result :2.5
select * from stu_tbl where stu_age>=20;-- Comparison operator
select * from stu_tbl where stu_name like '%a%';-- Comparison operator :like
select * from stu_tbl where stu_name like 'a___';-- Comparison operator :like
select * from stu_tbl where stu_age in(20,30);-- Comparison operator :in
select * from stu_tbl where stu_age between 20 and 30;-- Comparison operator :between
select stu_name from stu_tbl union all
select stu_name from stu_tbl_log;-- Set operators :union all
select stu_name from stu_tbl union
select stu_name from stu_tbl_log;-- Set operators :union
select stu_name from stu_tbl intersect
select stu_name from stu_tbl_log;-- Set operators :intersect
select stu_name from stu_tbl minus
select stu_name from stu_tbl_log;-- Set operators :minusIt can be seen from it that :
minus Is to get the data unique to the first table
intersect It is to obtain the data in both tables
union Is to integrate the data of two tables , All of them are displayed only once
union all It is pure data integration of two tables
select id,stu_name||' '||stu_sex as name_sex,stu_age
from stu_tbl;-- Join operators ||8.SQL function
One line function : Only one value is returned for each row queried from the table , Can appear in select Clause ,where clause
Date function
Number function
Character functions
Conversion function :ToChar(),ToDate(),ToNumber()
Other functions :
Nvl(exp1,exp2): Expression 1 is null when , Return expression two
Nvl2(exp1,exp2,exp3): Expression 1 is null Returns expression three , Otherwise, it returns expression two
Nullif(exp1,exp2): When two expressions are equal , return null, Otherwise, return the expression one
Group function : Return based on a set of rows
Avg,Min,Max,Sum,Count
Group by,having
Analysis function
Row_number,rank,dense_rank
Example :
select u.user_name,sum(oi.order_num*oi.order_price) as total,row_number() over (order by sum(oi.order_num*oi.order_price) desc) as sort from order_item_tbl
oi,user_tbl u,order_tbl o where oi.order_id = o.id and o.user_id = u.id group by u.user_name;边栏推荐
- Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
- Eight year test old bird, some suggestions for 1-3 year programmers
- The culprit of unrestrained consumption -- Summary
- CSP window
- The difference between objects and objects
- NLP Chinese corpus project: large scale Chinese natural language processing corpus
- Detailed explanation of the relationship between Zhongtai, wechat and DDD
- Sorry, Tencent I also refused
- Windos10 reinstallation system tutorial
- OS interrupt mechanism and interrupt handler
猜你喜欢
![[about text classification trick] things you don't know](/img/c0/fdb04f6b31f1dba2658c2430dc4036.jpg)
[about text classification trick] things you don't know

Regular expression of shell script value

OS interrupt mechanism and interrupt handler
![[CSDN Q & A] experience and suggestions](/img/db/dff3173dda24ca5740729b54a81153.jpg)
[CSDN Q & A] experience and suggestions

Test the influence of influent swacth on the electromagnetic coil of quartz meter

BBS forum recommendation

Cloud dial test helps Weidong cloud education to comprehensively improve the global user experience

The FISCO bcos console calls the contract and reports an error does not exist

Generic

@EnableAsync @Async
随机推荐
PMP 考试常见工具与技术点总结
1214 print diamond
Makefile judge custom variables
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
国元证券开户是真的安全可靠吗
Pair
A-Frame虚拟现实开发入门
MySQL winter vacation self-study 2022 12 (2)
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
2022 Software Test Engineer skill list, please check
Development and application of fcitx functional plug-ins
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
What are the application fields of digital twins in industry?
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
AI Challenger 2018 text mining competition related solutions and code summary
Entropy and full connection layer
From functools import reduce -- see the use of reduce function from typical examples
On covariance of array and wildcard of generic type
Detailed explanation of the relationship between Zhongtai, wechat and DDD