1.数据库的连接
使用以下配置
jdbc3.postgre.driverClassName=org.postgresql.Driver jdbc3.postgre.url=jdbc:postgresql://localhost:5432/postgres #最后为数据库名 jdbc3.postgre.username=xxxx jdbc3.postgre.password=xxxxxx
2.创建主键自增的表(使用图形化界面navicat创建表的时候并没有找到主键自增的设置,所以只能使用sql语句),
A.使用serial关键字 ,这个方法是默认为id创建了一个序列,默认值为:nextval('test_1_id_seq'::regclass)
create table test _1( id serial not null,name varchar(255) );
B.手动为table 创建序列
create sequence test_seq start with 1 increment by 1 no maxvalue no minvalue cache 1; alter table test_1 alter column id set default nextval('test_seq');
3.还有一点问题还没搞明白,我用图形化界面创建的表设置了主键,在导出sql语句转移到其他数据库的时候主键的设置会报错,移除设置主键的语句之后就好了
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。