这篇文章主要介绍“postgresql常用的sql语句分享”,在日常操作中,相信很多人在postgresql常用的sql语句分享问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”postgresql常用的sql语句分享”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
sql语句
15个常用的语句:
1.select relname,relpages from pg_class order by relpages desc
2.selecr pg_database_size('数据库名')
3.select pg_size_pretty(pg_total_relation_size('表名‘))
4.\d 表名
5.create index name on table using index_type(colum)
6.rollback,commit
7.explain query
8.explain analyze query
9.insert into number(num) values (generate_series(1,1000))
10.select count(*) from table ,select count(col_name) from table,
select count(distinct 列名) from table
11.slect MAX(num) from number_table where num < (select MAX(num) from number_table)
12.select MIN(col_name) from number_table where num >(select MIN(num) from number_table)
13.select typname,typlen from pg_type where typtype = 'b'
14.\g output_file,select * from table_name,\g
15.加密:select crypt('sathiys',gen_salt('md5'));
16.insert into WU(a1,b1) select generate_series(1,1000000),'aa';
17.select name,setting,short_desc from pg_settings where name like '%scan';
到此,关于“postgresql常用的sql语句分享”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!