当前位置:网站首页>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;边栏推荐
- [error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)
- Test the influence of influent swacth on the electromagnetic coil of quartz meter
- URL (data:image/png; Base64, ivborw0k... Use case
- A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
- Network layer - routing
- What does redis do? Redis often practices grammar every day
- STM32 key light
- Understanding of Radix
- Axure resources and prototype tool Axure RP 9 download
- Generic
猜你喜欢

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

Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
![[GNN] hard core! This paper combs the classical graph network model](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[GNN] hard core! This paper combs the classical graph network model

打印菱形图案

Regular expressions and text processors for shell programming

Generic

Beijing invites reporters and media

OS interrupt mechanism and interrupt handler

Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools

2-Redis架构设计到使用场景-四种部署运行模式(下)
随机推荐
打印菱形图案
8. Go implementation of string conversion integer (ATOI) and leetcode
[CSDN Q & A] experience and suggestions
Weekly open source project recommendation plan
Eight year test old bird, some suggestions for 1-3 year programmers
[about text classification trick] things you don't know
NLP Chinese corpus project: large scale Chinese natural language processing corpus
MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
Global and Chinese market of underwater bags 2022-2028: Research Report on technology, participants, trends, market size and share
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
[common error] custom IP instantiation error
PMP 考试常见工具与技术点总结
老姜的特点
Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
1214 print diamond
关于 uintptr_t和intptr_t 类型
ISBN number
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
The FISCO bcos console calls the contract and reports an error does not exist
Why use get/set instead of exposing properties