DROP FUNCTION IF EXISTS your_function_name(argument_types); 删除索引: sql DROP INDEX IF EXISTS your_index_name; 在这些示例中,将your_table_name、your_view_name、your_function_name(argument_types)和your_index_name替换为你要删除的实际对象名称和参数类型即可。 总结来说,使用DROP ... IF EXISTS语句可以安全地删除一个对象,而无需事先检查它...
DROPFUNCTION[IFEXISTS] 函数名 [([参数模式] [参数名] 参数类型)] [CASCADE|RESTRICT] DROPFUNCTION:删除一个函数 IFEXISTS: 如果函数不存在则不抛出错误而是报告消息 CASCADE :自动删除依赖于该函数的对象(如:触发器,操作符),然后删除所有依赖于该对象的对象 RESTRICT :如果有任何对象依赖于该函数则拒绝删除,默...
DROP FUNCTIONDROP FUNCTION — 移除一个函数大纲DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...] [ CASCADE | RESTRI… 阅读全文 五十九、DROP DOMAIN DROP DOMAINDROP DOMAIN — 移除一个域大纲DROP DOMAIN [ IF EXISTS ] name [, .....
drop function [if exists] function1, function2, ...; PostgreSQL Drop Function examples The following statement uses the create function statement to define a function that returns a set of films including film_id, title, and actor: create or replace function get_film_actors() returns setof ...
$function$;ALTERFUNCTIONpublic.function2(charactervarying,integer,timestampwithout time zone) OWNERTOpostgres; 其中用IF EXISTS判断表是否存在,存在则删除 DROPTABLEIFEXISTStableName
DROPTABLEIFEXISTSyour_table_name; 如果表存在,则将其删除;如果表不存在,则不执行任何操作。 使用PL/pgSQL函数:可以编写一个PL/pgSQL函数来检查表是否存在,并在需要时抛出自定义错误。 代码语言:sql 复制 CREATEORREPLACEFUNCTIONcheck_table_exists(table_nametext)RETURNSbooleanAS$$DECLAREtable_existsbo...
drop function if exists str_to_tsquery(text,boolean); create or replace function str_to_tsquery(text,boolean default true) returns tsquery as $$ declare v_count integer; v_txt text; v_txts text[]; v_result tsquery; begin v_txt := clear_punctuation($1); --数组大小为字符数量-1 v_co...
[PostgreSql]PostgreSql调⽤函数及⽤IFEXISTS判断表是否存在1.创建⼀个函数function1 -- FUNCTION: public.function1(character varying, integer)-- DROP FUNCTION public.function1(character varying, integer);CREATE OR REPLACE FUNCTION public.function1(useridl character varying,groupidl integer)RETURNS TABLE...
>= $1; drop function if exists gen_random_zh(int,int); create or replace function gen_random_zh(int,int) returns text as $$ select string_agg(chr((random()*(20901-19968)+19968 )::integer) , '') from generate_series(1,(random()*($2-$1)+$1)::integer); $$ language sql; -...
DROP ROLE [ IF EXISTS ] _name_ [, ...]DROP RULE删除一个重写规则。DROP RULE name ON relation [ CASCADE | RESTRICT ]DROP SCHEMA删除一个模式。DROP SCHEMA name [, ...] [ CASCADE | RESTRICT ]DROP SEQUENCE删除一个序列。DROP SEQUENCE name [, ...] [ CASCADE | RESTRICT ]...