
正文
关于postgresql判断的信息
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
postgresql 怎么判断一个字符串是否是数字
1.使用Character.isDigit(char)判断 char num[] = str.toCharArray();//把字符串转换为字符数组 StringBuffer title = new StringBuffer();//使用StringBuffer类,把非数字放到title中 StringBuffer hire = new StringBuffer();
相关问答
Q1: postgresql 如何判断表已存在
SELECT
schemaname,
tablename,
tableowner
FROM
pg_tables
LIMIT 10;
schemaname | tablename | tableowner
------------+------------------+------------
pg_catalog | pg_statistic | postgres
pg_catalog | pg_type | postgres
public | test_create_tab | postgres
public | test_create_tab1 | postgres
public | test_create_tab2 | postgres
public | test_create_tab4 | postgres
public | MR_DEPT | postgres
pg_catalog | pg_authid | postgres
pg_catalog | pg_attribute | postgres
pg_catalog | pg_proc | postgres
(10 行记录)
不知道通过上面的 sql 语句, 你是否能明白。
如果你要判断 某个表是否存在, 只需要在上面的 Sql 的基础上, 增加 tablename = '你的表名'
Q2: postgresql如何更新插入一起判断执行??
可以先执行update语句(update的条件是存在的判断条件),然后调用get diagnostics获得上一个SQL语句执行所影响的行数,如果影响行数为0,则说明不存在,那么再执行insert语句。
结构类似:
declare
v_cnt integer;
begin
update .... -- 执行更新语句
where ...; -- 这里的条件是存在的判断条件
get diagnostics v_cnt = row_count; -- 将影响行数的值赋给v_cnt
if v_cnt = 0 then
insert into ...; -- 执行插入语句
end if;
end;






