SELECT tbl.tablename AS 表名, a.attnum AS 字段顺序, a.attname AS 字段名, pg_type.typname AS 字段类型, col_description(a.attrelid, a.attnum) AS 注释, case a.attnotnull when 'f' then '否' when 't' then '是' end AS 是否必填
FROM pg_tables tbl, pg_class c, pg_attribute a, pg_type
WHERE tbl.schemaname = 'wirelessresource'
AND pg_type.oid = a.atttypid
AND tbl.tablename = c.relname
AND a.attrelid = c.oid
AND a.attnum > 0
ORDER BY tbl.tablename, a.attnum;
在navicat中可以直接导出结果为excel格式
SELECT tbl.tablename AS 表名, a.attnum AS 字段顺序, a.attname AS 字段名, pg_type.typname AS 字段类型, col_description(a.attrelid, a.attnum) AS 注释, case a.attnotnull when 'f' then '否' when 't' then '是' end AS 是否必填...
import random
import psyco
pg
2
fname=['金','赵','李','陈','许','龙','王','高','张','侯','艾','钱','孙','周','郑']
mname=['玉','明','玲','淑','偑','艳','大','小','风','雨','雪','天','水','奇','鲸','米','晓','泽','恩','葛','玄','道','振','隆','奇']
lname=['','玲','','芳','明','红','国
select
(select relname ||’–’||(select description from
pg
_description where objoid = oid and objsubid = 0) from
pg
_class where oid=a.attrelid) as 表名,
a.attname as 列名,
format_type(a.atttypid,a.atttypmod) as 类型,
(case when atttypmod-4>0 then atttypmod-4 e
select conname,conkey,conrelid from
pg
_constraint;
--将主键约束数组分解为结果集
select conname,unnest(conkey),conrelid from
pg
_constraint;
--获取public名...
Postger
SQL
的jar包版本:
postgresql
-9.3-1102-jdbc4.jar
mybatis-generator版本:mybatis-generator-core-1.3.7.jar
关于逆向工程自动
生成
dao层代码的功能,网上很多介绍的都是my
sql
版本的,而且介绍的都是在开发环境idea或eclipse中怎么使用,这里整理的是Postger
SQL
版本的,而且是单独使用的方法(附jar包,修配置文件直接可以使用),
生成
dao层文件后,把需要的代码拷贝到自己项目上去即可。
生成
的文件内容比较齐全,xml文件包括对应表格的操作包括select、update、delete、insert。这里需要说明一点,如果要操作的表没有主键字段,则
生成
的xml中只有insert,没有select、update、delete,因为这三种操作都与主键有关,如deleteByPrimaryKey(Long id)、selectByPrimaryKey(Long id)、updateByPrimaryKey(InRoomInfoDao record)。
select
(select relname||'--'||(select description from
pg
_description where objoid=oid and objsubid=0) as comment from
pg
_class where oid=a.attrelid) as table_name,
a.attname as column_name,
可以使用Java中的JDBC API来连接
PostgreSQL
数据库并
生成
代码。首先,需要下载并安装
PostgreSQL
JDBC驱动程序。然后,可以使用以下代码来连接数据库:
import java.
sql
.*;
public class
PostgreSQL
JDBC {
public static void main(String args[]) {
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.
postgresql
.Driver");
c = DriverManager
.getConnection("jdbc:
postgresql
://localhost:5432/testdb",
"username", "password");
System.out.println("Opened database successfully");
stmt = c.createStatement();
String
sql
= "CREATE TABLE COMPANY " +
"(ID INT PRIMARY KEY NOT NULL," +
" NAME TEXT NOT NULL, " +
" AGE INT NOT NULL, " +
" ADDRESS CHAR(50), " +
" SALARY REAL)";
stmt.executeUpdate(
sql
);
stmt.close();
c.close();
} catch (Exception e) {
System.err.println(e.getClass().getName()+": "+e.getMessage());
System.exit(0);
System.out.println("Table created successfully");
这段代码会创建一个名为COMPANY的表。可以根据需要修改代码以
生成
其他类型的代码。
重协商攻击(CVE-2011-1473) 漏洞处理
qq_32240521: