随笔分类 - SQL
摘要:7.2. Table Expressions To put this together, assume we have tables t1: and t2: then we get the following results for the various joins: The join condi
阅读全文
摘要:SQL语句case when外用sum与count的区别 三个case语句效果相同,其实就是类似于增加一个字段,这个字段,满足条件的为1,不满足的是0,这样sum的效果,就是将所有的1加起来,也就是所有满足条件的记录个数。 而count,会不管是1还是0,都会统计,这样怎么算都是总条目数8个。 9.
阅读全文
摘要:PostgreSQL 与基友们的故事之 - Redis 在PostgreSQL中直接读写redis。好处多多,可以降低应用层设计的复杂度,减少交互次数,降低RT。应用场景举例:.1. 使用redis作为PostgreSQL的二级缓存, 提升数据库的性能。例如在生产中有多台redis主机或集群,使用r
阅读全文
摘要:Perform the same operation and return the updated entries:
阅读全文
摘要:select * from pg_type where typname = 'managertype'; typname | typnamespace | typowner | typlen | typbyval | typtype | typcategory | typispreferred |
阅读全文
摘要:test=> select * from favoriteguidance test-> ; userid | createtime | objectcreatetime | title | objectid -----------+-------------------------------+-------...
阅读全文
摘要:--备份用户mew的数据库mew的所有内容 pg_dump -U mew -d mew -h localhost > mew.sql --删除原有数据库 dropdb -U mew -h localhost mew --创建数据库 createdb -U mew -h localhost mew --恢复数据库 psql -U mew -d mew -h localhost < mew.sql...
阅读全文
摘要:删除ask时报错 因为将主键设置为 primary key(userID,objectID),因而objectID不能为空,所以删除时报错了
阅读全文
摘要:PostgreSQL: Documentation: 9.6: ALTER TABLE 例子: alter table ask add column commentCount int not null default 0; mew=# drop type gradetype cascade;注意:
阅读全文
摘要:{"/image/ask/100002769image12017-07-24 15:56:56.243105236 +0800 CST m=+0.328076257.jpg","/image/ask/100002769image22017-07-24 15:56:56.280911621 +0800
阅读全文
摘要:一般性 \copyright 显示PostgreSQL的使用和发行许可条款 \errverbose 以最冗长的形式显示最近的错误消息 \g [文件] or; 执行查询 (并把结果写入文件或 |管道) \gexec 执行策略,然后执行其结果中的每个值 \gset [PREFIX] 执行查询并把结果存到
阅读全文
摘要:原来的表: 这里通过评论对象来分类 对于@nickname这种评论评论的,objectName = "comment",objectID = comment.id,publisherID为被@的人,但这样在同一个object的评论时@nickname这种很难处理 修改后的表: 这里通过评论所属对象来
阅读全文
摘要:postgresql默认全部小写,若要区分字段名大小写需要用引号括住
阅读全文
摘要:insert test=> insert into ask(id,publisherID,reward,cost,rangee,typee,label,content,image,createTime,zan,school,college) valuestest-> (1,1,4,10,'schoo
阅读全文
摘要:官方网站 In addition to simply finding the rows to be returned by a query, an index may be able to deliver them in a specific sorted order. This allows a
阅读全文
摘要:官网文档 Since a DELETE of a row from the referenced table or an UPDATE of a referenced column will require a scan of the referencing table for rows match
阅读全文
摘要:这样rows里存的是第一条命令的结果 但prepare时不允许多条命令,会报错 pq: 无法插入多条命令到一个准备好的语句中
阅读全文
摘要:转自 PostgreSQL 添加各种约束语法 1. 添加主键 alter table goods add primary key(sid); 2. 添加外键 alter table orders add foreign key(goods_id) references goods(sid) on u
阅读全文
摘要:postgres: /etc/postgresql/9.5/main/ environment pg_ctl.conf pg_hba.conf pg_ident.conf postgresql.conf start.conf postgresql.conf 修改: pg_hba.conf修改: mo
阅读全文

浙公网安备 33010602011771号