zoukankan      html  css  js  c++  java
  • pg psql命令

    linux下使用psql命令操作数据库

    下面主要用到了insert into  ,pg_dump  , pg_restore 命令

    按步骤走

    su postgres                          切换指定用户

    pg_restore -d mydb /mnt/mydb.backup                        mydb指定数据库     mydb.backup    恢复的文件

    ALTER TABLE table1 RENAME TO table2;             给表重命名  把表1改成表2

    insert into table1  select name,age,height from student where add_time <'2013-10-01';    insert into 的使用   table1必须存在

    select * into table1 from student where name like '%杉%';      select into的使用    talbe1必须不存在 把查询到的数据插入到table1

    psql -d xxx                          xxx指定数据库

    dt                                     查看当前数据库非系统表

    c   xx            切换指定db;

    select * from student;                           注意一定带上分号 ";" 表示命令的结束

    q           退出psql模式

    备份指定表

    pg_dump --host localhost --port 5432 --username "sqluser" --format custom --blobs --encoding UTF8 --ignore-version --verbose 数据库 -t 表 --file /mnt/11.backup

    恢复指定表

    pg_restore -d 数据库 /mnt/11.backup 

  • 相关阅读:
    刚下飞机——Alpha冲刺 总结随笔
    刚下飞机——Alpha冲刺Day10
    刚下飞机——Alpha冲刺Day9
    刚下飞机——Alpha冲刺Day8
    刚下飞机——Alpha冲刺Day7
    快乐就队——Beta冲刺(1/7)
    快乐就队——凡事预则立
    快乐就队——Alpha冲刺问题总结&事后诸葛亮
    快乐就队——换组记录
    快乐就队——Alpha冲刺总结
  • 原文地址:https://www.cnblogs.com/sheapchen/p/3376576.html
Copyright © 2011-2022 走看看