zoukankan      html  css  js  c++  java
  • postgresql数据操作

    windows下操作postgresql

    删除数据库:
    dropdb.exe -U postgres 数据库名称

    创建数据库
    createdb.exe -U postgres lilei_db1
    --lilei_db1为数据库名称

    导出表数据
    pg_dump.exe -U postgres -t tab1 -d postgis_24_sample > tab1.sql
    pg_dump.exe --help 查看帮助信息
    -U 用户名
    -t 表名称
    -d 数据库名称

    导入数据
    psql -d lilei_db1 -U postgres -f all_db.sql
    -f sql文件

    关闭自动提交
    begin;
    scripts;
    commit;

    获取表的列结构
    select * from information_schema.columns where table_name='link';

    查询当前正在执行sql的会话
    select * from pg_stat_activity where state!='idle';

    获取表存储空间占用
    select pg_size_pretty(pg_relation_size('link'));

    select pg_relation_size('link');

    获取几何线长度
    select st_length(st_setsrid(geom,4326),false) from link5 where id=20357;
    --添加参数false,否则是平面距离

    附属帮助
    l 显示所有数据库
    d 显示当前库所有表、序列、视图
    dt 显示当前库所有表
    d admin_face 显示admin_face表结构

    set autocommit off 关闭自动提交

  • 相关阅读:
    Linux中的中断处理
    Yocto使用小技巧
    udev学习笔记汇总
    USB gadget学习笔记
    Linux常用命令
    Linux下软件安装方法
    278. First Bad Version
    MySQL的索引
    7. Reverse Integer
    排序算法
  • 原文地址:https://www.cnblogs.com/lilei2blog/p/8582596.html
Copyright © 2011-2022 走看看