• 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 

  • 相关阅读:
    jmeter上做分布压测
    jpg,jpeg,bmp,png,gif图片格式区别
    jmeter的命令行进行压力测试
    Java8新特性
    02-Git
    01-Maven
    Java-集合
    Java-I/O框架
    mongodb安装配置
    Nginx常见错误及处理方法
  • 原文地址:https://www.cnblogs.com/sheapchen/p/3376576.html
Copyright © 2020-2023  润新知