相关疑难解决方法(0)

关系数据库中的目录和模式之间有什么区别?

我曾经认为模式是数据库本身之前的"上层包装"对象.我的意思DB.schema.<what_ever_object_name_under_schema>.

那么,目录"包装器"现在非常令人困惑.我们为什么需要目录?出于何种目的,目前应该使用目录?

database schema catalog

86
推荐指数
2
解决办法
7万
查看次数

search_path如何影响标识符解析和"当前架构"

是否可以定义默认情况下创建新表的模式?(由"不合格的表名称"引用.)

我已经看到了在Postgres中使用"搜索路径"的一些细节,但我认为它只在检索数据时有效,而不是创建.

我有一堆SQL脚本,它们创建了许多表.我没有修改脚本,而是希望默认情况下在特定模式中设置数据库创建表 - 当它们具有非限定名称时.

这可能吗?

postgresql schema search-path database-table

46
推荐指数
2
解决办法
3万
查看次数

表分区与包含许多索引的非分区表

我有一个带有主表的数据库"DB_One",上面t_d_gate_out有8个索引.我创建了另一个带分区的数据库t_d_gate_out(让我们称之为"DB_Two").:它是由年份和月份(子表的例子分区t_d_gate_out09-2013有两个索引)(d _gate_out和每个孩子新列:i_trx_own)

这是我创建和插入子表的功能:

CREATE OR REPLACE FUNCTION ctm_test.gateout_partition_function()
  RETURNS trigger AS
$BODY$ 
DECLARE new_time text;
tablename text;
seqname text;
seqname_schema text;
bulantahun text;
bulan text;
bulan2 text;
tahun text;
enddate text;
result record;

BEGIN new_time := to_char(NEW.d_gate_out,'MM-YYYY');
bulan:=to_char(NEW.d_gate_out,'MM');
bulan2:=extract(month from NEW.d_gate_out);
tahun:=to_char(NEW.d_gate_out,'YYYY');
bulantahun := new_time;
tablename := 't_d_gate_out'||bulantahun;
seqname := 't_d_gate_out'||bulantahun||'_seq';
seqname_schema := 'ctm_test.t_d_gate_out'||bulantahun||'_seq';

PERFORM 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE 

c.relkind = 'r' AND …
Run Code Online (Sandbox Code Playgroud)

postgresql indexing partitioning postgresql-performance

5
推荐指数
1
解决办法
1916
查看次数

在继承的表上使用触发器来替换外键

我是PostgreSQL的新手.我有这样的表:

CREATE TABLE Person (
  ID SERIAL PRIMARY KEY,
  Name VARCHAR(32) NOT NULL DEFAULT '',
  Surname VARCHAR(32) NOT NULL DEFAULT '',
  Birthday DATE,
  Gender VARCHAR(8)
);

-- Student table inherits from person
CREATE TABLE Student (
  ID_Student SERIAL PRIMARY KEY,
  MajorDept VARCHAR(32),
) INHERITS(Person);

-- Student table inherits from person
CREATE TABLE Employee (
  ID_Employee SERIAL PRIMARY KEY,
  Position VARCHAR(32),
  Rank VARCHAR(32),
  Salary NUMERIC(12,2)
) INHERITS(Person);

-- Address table references person
CREATE TABLE Address (
  ID_Address SERIAL PRIMARY KEY,
  Person_id …
Run Code Online (Sandbox Code Playgroud)

postgresql inheritance triggers database-design referential-integrity

4
推荐指数
2
解决办法
2006
查看次数