当前位置:网站首页>Kingbasees SQL language reference manual of Jincang database (17. SQL statement: discard to drop language)
Kingbasees SQL language reference manual of Jincang database (17. SQL statement: discard to drop language)
2022-07-26 19:59:00 【Thousands of sails passed by the side of the sunken boat_】
17. SQL sentence : DISCARD To DROP LANGUAGE
This chapter contains the following SQL sentence :
17.1. DISCARD
purpose
DISCARD — Discard session state
DISCARDRelease internal resources related to a database session . This command helps to partially or completely reset the state of the session . There are several subcommands to release different types of resources .DISCARD ALLVariants include all other forms , It will also reset additional states .
precondition
nothing
grammar
DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }
semantics
PLANSRelease all cached query plans , Force you to reschedule the next time you use the relevant preparation statement .
SEQUENCESDiscard all cached sequence related states , Include ``currval()``/
lastval()Information and anything that has not beennextval()The pre allocated sequence value returned ( See CREATE SEQUENCE );
TEMPORARYorTEMPDelete all temporary tables created in the current session .
ALLRelease all temporary resources related to the current session and reset the session to its initial state . Currently, this has the same effect as executing the following statement sequence :
CLOSE ALL; SET SESSION AUTHORIZATION DEFAULT; RESET ALL; DEALLOCATE ALL; UNLISTEN *; SELECT sys_advisory_unlock_all(); DISCARD PLANS; DISCARD TEMP; DISCARD SEQUENCES;
Example
DISCARD SEQUENCES;
Compatibility
DISCARDIt's a kind of KingbaseES Expand .
other
DISCARD ALLCannot execute within a transaction block .
17.2. DO
purpose
DO — Execute an anonymous code block
DOExecute an anonymous code block , Or in other words, execute an instantaneous anonymous function written in a process language .The code block is like a code block that has no parameters and returns
voidThe function body of the function of . It will be parsed and executed in one time .Optional
LANGUAGEClause can be unloaded before or after the code block .
precondition
The process language to be used must already be used
CREATE LANGUAGEInstalled in the current database . It is installed by defaultplsql, But other languages are not installed .The user must have the
USAGEPrivilege , If the language is untrusted, it must be a super user . This is the same as the privilege requirements for creating a function in this language .
grammar
DO [ LANGUAGE lang_name ] code
semantics
codeThe process language code to be executed . As in the ``CREATE FUNCTION`` In the same , It must be specified as a string . It is recommended to use a dollar quoted text .
lang_nameThe name of the process language that wrote the code . If omitted , The default is
plsql.
Example
Put the pattern
publicAll privileges on all views in are granted to roleswebuser:DO $$DECLARE r record; BEGIN FOR r IN SELECT table_schema, table_name FROM information_schema.tables WHERE table_type = 'VIEW' AND table_schema = 'public' LOOP EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'; END LOOP; END$$;
Compatibility
SQL There is no in the standard
DOsentence .
17.3. DROP ACCESS METHOD
purpose
DROP ACCESS METHOD — Remove an access method
DROP ACCESS METHOD Remove an existing access method .
precondition
Only super users can delete access methods .
grammar
DROP ACCESS METHOD [ IF EXISTS ] name [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the access method does not exist , No error will be thrown . In this case, a prompt will be issued .
nameThe name of an existing access method .
CASCADEAutomatically delete objects that depend on this access method ( For example, operator class 、 Operator family and index ), And then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on this access method , Then refuse to delete it . This is the default setting .
Example
Delete access method
heptree:DROP ACCESS METHOD heptree;
Compatibility
DROP ACCESS METHODIt's a kind of KingbaseES Expand .
17.4. DROP AGGREGATE
purpose
DROP AGGREGATE — Remove an aggregate function
DROP AGGREGATERemove an existing aggregate function .
precondition
To execute this command , The current user must be the owner of the aggregation function .
grammar
DROP AGGREGATE [ IF EXISTS ] name ( aggregate_signature ) [, ...] [ CASCADE | RESTRICT ] here aggregate_signature yes : * | [ argmode ] [ argname ] argtype [ , ... ] | [ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
semantics
IF EXISTSIf the aggregation does not exist, do not throw an error , It's a reminder .
nameThe name of an existing aggregate function ( It can be pattern Limited ).
argmodeA parameter mode :
INorVARIADIC. If it's ignored , The default value isIN.
argnameThe name of a parameter . Be careful ``DROP AGGREGATE`` Don't really care about parameter names , Because only the parameter data type is needed to determine the identity of the aggregation function .
argtypeAn input data type that the aggregate function operates on . To reference an aggregate function with zero parameters , Write ``*`` To replace the parameter description list . To reference an ordered set aggregation function , Write
ORDER BY.
CASCADEAutomatically delete objects that depend on the aggregate function ( For example, use its view ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the aggregate function , Then refuse to delete it . This is the default .
Example
Type
integerRemove the aggregate functionmyavg:DROP AGGREGATE myavg(integer);To remove the hypothetical set aggregation function
myrank, This function receives an arbitrary list of permutations and a matching list of direct parameters :DROP AGGREGATE myrank(VARIADIC "any" ORDER BY VARIADIC "any");To delete multiple aggregate functions in one command :
DROP AGGREGATE myavg(integer), myavg(bigint);
Compatibility
stay SQL There is no in the standard
DROP AGGREGATEsentence .
other
ALTER AGGREGATE The following describes another syntax for referencing ordered set aggregation .
17.5. DROP CAST
purpose
DROP CAST — Remove a shape
DROP CASTRemove a previously defined shape .
precondition
To be able to delete a shape , You must have source data type or target data type . This is also the privilege required to create a shape .
grammar
DROP CAST [ IF EXISTS ] (source_type AS target_type) [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the shape doesn't exist, don't throw an error , It's a reminder .
source_typeThe name of the source data type of the shape .
target_typeName of the target data type of the shape .
CASCADEThis keyword has no effect , Because there is no dependence on the shape .
RESTRICTThis keyword has no effect , Because there is no dependence on the shape .
Example
To remove from type
textTo typeintThe modelling of :DROP CAST (text AS int);
Compatibility
DROP CASTThe command conforms to SQL standard .
17.6. DROP COLLATION
purpose
DROP COLLATION — Remove a collation
DROP COLLATIONRemove a previously defined collation .
precondition
To be able to delete a collation , You must have it .
grammar
DROP COLLATION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the collation does not exist, do not throw an error , It's a reminder .
nameThe name of the collation . The collation name can be schema qualified .
CASCADEAutomatically delete objects that depend on the collation , Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the collation , Then refuse to delete it . This is the default .
Example
To delete the name
germanCollation of :DROP COLLATION german;
Compatibility
except
IF EXISTSBeyond the options ,DROP COLLATIONThe command conforms to SQL standard . This option is a KingbaseES Expand .
17.7. DROP CONTEXT
purpose
DROP CONTEXTDelete context(userenv Cannot delete ). This information will be from pg_context In the table to delete .Delete context Will not make this context Set up under key-value invalid . however , When the user next attempts to set this context when , The context Will be invalid . That is, it deletes the dictionary object , The instance object will not be deleted .
precondition
Have the permission to delete objects .
grammar
DROP CONTEXT namespace
semantics
namespaceSpecify the... To delete context name . Cannot delete built-in context userenv.
Example
To delete the name context_test Of context:
drop context context_test;
17.8. DROP CONVERSION
purpose
DROP CONVERSION — Remove a transformation
DROP CONVERSIONRemove a previously defined transformation .
precondition
To be able to delete a transformation , You must have this conversion .
grammar
DROP CONVERSION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the transformation does not exist, do not throw an error , It's a reminder .
nameThe name of the transformation . The transformation name can be schema qualified .
CASCADEThis keyword has no effect , Because there is no dependency on transformation .
RESTRICTThis keyword has no effect , Because there is no dependency on transformation .
Example
To delete the name
mynameTransformation :DROP CONVERSION myname;
Compatibility
stay SQL There is no in the standard
DROP CONVERSIONsentence , But there is oneDROP TRANSLATIONsentence . And the correspondingCREATE TRANSLATIONsentence , It is associated with KingbaseES MediumCREATE CONVERSIONSentence similarity .
17.9. DROP DATABASE
purpose
DROP DATABASERemove a database . It will Remove the system directory entry of the database and delete the file directory containing the data . It can only be controlled by the database The owner executes . also , When you or anyone else has connected to the target database , It can't Be performed ( Connect tokingbaseOr any other database to send this An order ).
DROP DATABASECannot be revoked . Please use with care !
precondition
You must have this database to use DROP DATABASE .
grammar
DROP DATABASE [ IF EXISTS ] name
semantics
IF EXISTSIf the database does not exist, do not throw an error , It's a reminder .
nameName of the database to be removed .
Example
Delete database mydatabase
DROP DATABASE mydatabase;
Compatibility
SQL There is no in the standard
DROP DATABASEsentence .
other
DROP DATABASECannot execute within a transaction block .When connecting to the target database , This command cannot be executed . therefore , Use the program dropdb Will be more convenient , It is a wrapper for this command .
17.10. DROP DATABASE LINK
purpose
DROP DATABASE LINKRemove a database link. database link Can be owned and DBA Delete , Delete database link After object , All objects in the user session will be cleared .If database link Being used by other users , Cannot delete this database link.
Temporary does not support PUBLIC keyword .
precondition
To execute this command, you must have this database link Authority .
grammar
DROP DATABASE LINK dblink_name
semantics
dblink_nameTo delete
DATABASE LINKname , You can include the schema name .
Example
Delete mydblink
DROP DATABASE LINK mydblink;
17.11. DROP DIRECTORY
purpose
DROP DIRECTORYRemove a directory .
precondition
Only superuser You can remove directories .
grammar
DROP DIRECTORY [ IF EXISTS ] (public.)dir_name
semantics
IF EXISTSIf the directory does not exist, do not throw an error , It's a reminder .
dir_nameThe name of an existing directory ( The default is public Pattern , Can be specified as public Pattern , Specify other modes to report errors ).
Example
To remove a directory :
DROP DIRECTORY dir_name;
Compatibility
except
IF EXISTSOptions , This command conforms to SQL standard . This option is a KingbaseES Expand .
17.12. DROP DOMAIN
purpose
DROP DOMAIN — Remove a domain
DROP DOMAINRemove a domain .
precondition
Only the owner of the domain To remove it .
grammar
DROP DOMAIN [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the domain does not exist, do not throw an error , It's a reminder .
nameThe name of an existing domain ( It can be pattern Limited ).
CASCADEAutomatically delete objects that depend on this domain ( For example, table columns ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on this domain , Then refuse to delete it . This is the default .
Example
To remove a domain
box:DROP DOMAIN box;
Compatibility
except
IF EXISTSOptions , This command conforms to SQL standard . This option is a KingbaseES Expand .
17.13. DROP EVENT TRIGGER
purpose
DROP EVENT TRIGGER — Remove an event trigger
precondition
To execute this command , The current user must be the owner of the event trigger .
grammar
DROP EVENT TRIGGER [ IF EXISTS ] name [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the event trigger does not exist, do not throw an error , It's a reminder .
nameName of the event trigger to remove .
CASCADEAutomatically delete objects that depend on this trigger , Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on this trigger , Then refuse to delete it . This is the default .
Example
Destroy trigger
snitch:DROP EVENT TRIGGER snitch;
Compatibility
stay SQL There is no in the standard
DROP EVENT TRIGGERsentence .
17.14. DROP EXTENSION
purpose
DROP EXTENSION — Remove an extension
DROP EXTENSIONRemove the extension from the database . Deleting an extension will cause its constituent objects to be deleted .
precondition
You must have this extension to use
DROP EXTENSION.
grammar
END [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
semantics
IF EXISTSIf the extension does not exist, do not throw an error , It's a reminder .
nameName of an installed extension .
CASCADEAutomatically delete objects that depend on this extension , Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on this extension ( Instead of having its own member objects and others listed in the same
DROPExtensions in the command ), Then refuse to delete it . This is the default .
Example
To remove an extension from the current database
hstore:DROP EXTENSION hstore;If
hstoreAny object of is in use in this database , For example, the column of a table ishstoretype , This command will fail . addCASCADEOption can force these dependent objects to be removed .
Compatibility
DROP EXTENSIONIt's a KingbaseES Expand .
17.15. DROP FOREIGN DATA WRAPPER
purpose
DROP FOREIGN DATA WRAPPER — Remove an external data wrapper
DROP FOREIGN DATA WRAPPERRemove an existing external data wrapper .
precondition
To execute this command , The current user must be the owner of the external data wrapper .
grammar
DROP FOREIGN DATA WRAPPER [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the external data wrapper does not exist, do not throw an error , It's a reminder .
nameThe name of an existing external data wrapper .
CASCADEAutomatically delete objects that depend on the external data wrapper ( For example, server ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the external data wrapper , Then refuse to delete it . This is the default .
Example
Delete external data wrapper
dbi:DROP FOREIGN DATA WRAPPER dbi;
Compatibility
DROP FOREIGN DATA WRAPPERaccord with ISO/IEC 9075-9 (SQL/MED).IF EXISTSClause It's a KingbaseES Expand .
17.16. DROP FOREIGN TABLE
purpose
DROP FOREIGN TABLE — Remove an external table
DROP FOREIGN TABLERemove an external table .
precondition
Only the owner of an external table can remove it .
grammar
DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the external table does not exist, do not throw an error , It's a reminder .
nameName of the external table to delete ( It can be pattern Limited ).
CASCADEAutomatically delete objects that depend on the external table ( For example, view ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the external table , Then refuse to delete it . This is the default .
Example
To destroy two external tables
filmsanddistributors:DROP FOREIGN TABLE films, distributors;
Compatibility
This command conforms to ISO/IEC 9075-9 (SQL/MED), However, the standard allows only one external table to be deleted in each command without
IF EXISTSOptions . This option is a KingbaseES Expand .
17.17. DROP FUNCTION
purpose
DROP FUNCTIONRemove the definition of an existing function . The parameter type of this function must be specified , Because many different functions may have the same function name and different parameter lists .
precondition
To execute this command, the user must be the owner of the function .
grammar
DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...] [ CASCADE | RESTRICT ]
semantics
IF EXISTSIf the function does not exist, do not throw an error , It's a reminder .
nameThe name of an existing function ( It can be pattern Limited ). If no parameter list is specified , Then the name must be unique in its schema .
argmodeA parameter mode :
IN、OUT、INOUTperhapsVARIADIC. If it's ignored , The default isIN. Be carefulDROP FUNCTIONDon't really care aboutOUTParameters , Because you only need to input parameters to determine the identity of the function . So listIN、INOUTandVARIADICThe parameters are sufficient .
argnameThe name of a parameter . Be careful
DROP FUNCTIONDon't really care about parameter names , Because only the data type of the parameter is needed to determine the identity of the function .
argtypeIf the function has parameters , This is the data type of the function parameter ( It can be pattern Limited ).
CASCADEAutomatically delete objects that depend on this function ( Such as operators and triggers ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on this function , Then refuse to delete it . This is the default .
Example
This command removes the square root function :
DROP FUNCTION sqrt(integer);Delete multiple functions in one command :
DROP FUNCTION sqrt(integer), sqrt(bigint);If the function name is unique in its schema , You can reference it without a parameter list :
DROP FUNCTION update_employee_salaries;Please note that , This is related to
DROP FUNCTION update_employee_salaries();Different , The latter refers to a function with zero parameters , The first variant can refer to functions with any number of parameters , Including zero , As long as the name is unique .
Compatibility
This command complies with SQL standard , Use these KingbaseES Expand :
This standard allows only one function to be deleted per command .
IF EXISTSOptionsCan specify parameter mode and name
17.18. DROP GROUP
purpose
DROP GROUP — Remove a database role
DROP GROUPNow it is DROP ROLE An alias for .
precondition
See DROP ROLE
grammar
DROP GROUP [ IF EXISTS ] name [, ...]
semantics
IF EXISTSDon't throw an error if the role doesn't exist , It's a reminder .
nameThe name of the role to be removed .
Example
DROP GROUP regress_priv_group1;
Compatibility
stay SQL There is no in the standard
DROP GROUPsentence .
17.19. DROP INDEX
purpose
DROP INDEXRemove an existing index from the database system .
precondition
To execute this command, you must be the owner of the index .
grammar
DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
semantics
CONCURRENTLYDelete the index without blocking the concurrent selection on the index base table 、 Insert 、 Update and delete operations . One ordinary
DROP INDEXWill require the exclusive lock on the form , This will block Other accesses until the index deletion is completed . With this option , The command will wait until the conflicting transaction is completed .There are some things to pay attention to when using this option . Only one index name can be specified , And don't support a
CASCADEOptions ( therefore , One supportUNIQUEperhapsPRIMARY KEYConstrained indexes cannot be deleted in this way ). also , routine OfDROP INDEXCommands can be executed within a transaction block , andDROP INDEX CONCURRENTLYYou can't .
IF EXISTSIf the index does not exist, do not throw an error , It's a reminder .
nameThe name of the index to be removed ( It can be pattern Limited ).
CASCADEAutomatically delete objects that depend on the index , Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the index , Then refuse to delete it . This is the default .
Example
This command will remove the index
title_idx:
DROP INDEX title_idx;
Compatibility
DROP INDEXIt's a KingbaseES Language extension . stay SQL There is no stipulation about index in the standard .
17.20. DROP LANGUAGE
purpose
DROP LANGUAGE — Remove a process language
DROP LANGUAGERemove the definition of a previously registered process language .
precondition
You must be a super user or the owner of the language to use ``DROP LANGUAGE``.
grammar
DROP [ PROCEDURAL ] LANGUAGE [ IF EXISTS ] name [ CASCADE | RESTRICT ]
semantics
IF EXISTSDo not throw an error if the language does not exist , It's a reminder .
nameThe name of an existing process language . For forward compatibility , This name can be enclosed in single quotation marks .
CASCADEAutomatically delete objects that depend on the language ( For example, functions in this language ), Then delete all objects that depend on those objects ( see Rely on tracking ).
RESTRICTIf any object depends on the language , Then refuse to delete it . This is the default .
Example
This command removes the process language
plsample:DROP LANGUAGE plsample;
Compatibility
stay SQL There is no in the standard
DROP LANGUAGEsentence .
边栏推荐
- Collection of original IOS interview questions
- 京东荣获中国智能科学技术最高奖!盘点京东体系智能技术
- 2022/07/26 learning notes (day16) linked list and stack
- 金仓数据库 KingbaseES SQL 语言参考手册 (17. SQL语句: DISCARD 到 DROP LANGUAGE)
- LeetCode每日一练 —— 88. 合并两个有序数组
- 负载均衡的使用
- How to adjust the abnormal win11 USB drive to normal?
- [internship experience] exception handling and URL result response data processing
- What is federated graph machine learning? A summary of the latest "federal map machine learning: concepts, techniques, and Applications" at the University of Virginia
- Kingbases SQL language reference manual of Jincang database (15. SQL statement: create materialized view to create schema)
猜你喜欢
随机推荐
svn使用碎碎念
计算机组成原理常见面试题目总结,含答案
企业数字化转型成大趋势,选对在线协作工具很重要
Server memory failure prediction can actually do this
花1200亿修一条“地铁”,连接4个万亿城市,广东在想啥?
EFCore Migrations的深入研究
IM即时通讯开发如何压缩移动网络下APP的流量消耗
go+mysql+redis+vue3简单聊室,第6弹:使用vue3和element-plus调用接口
Three paradigms of database design
Talk about how to use redis to realize distributed locks?
2022年下半年(软考高级)信息系统项目管理师报名条件
Design of intelligent weighing system based on Huawei cloud IOT (STM32) [i]
猎聘问卷星,成为微信「寄生虫」
Software testing - what are the automated testing frameworks?
Leetcode daily practice - 27. Remove elements
拿铁DHT-PHEV产品响当当,销量会不会让李瑞峰想通了呢?
上半年住户存款增加10.33万亿元,平均每天约571亿存款涌向银行
How to compress the traffic consumption of APP under mobile network in IM development
移动端video兼容你需要知道的几点
LeetCode每日一练 —— 27. 移除元素









