如何从Postgresql数据库中选择我想要的模式?

时间:2014-10-29 21:11:54

标签: php postgresql

我有两个模式,一个叫做public,另一个叫做SIEM。 我想从SIEM模式打印一个表,但它不打印任何东西。 如何从?

中选择要打印表格的模式
$query = "SELECT * from Maquina222";

$result = pg_query($conn,$query);

$i = 0;
echo '<html><body><table><tr>';
while ($i < pg_num_fields($result))
{ 
   $fieldName = pg_field_name($result, $i); 
   echo '<td>' . $fieldName . '</td>'; 
   $i = $i + 1;
}
echo '</tr>';

$i = 0;

while ($row = pg_fetch_row($result)) 
{ 
    echo '<tr>'; 

    $count = count($row); 
    $y = 0;
    while ($y < $count)
    { 
        $c_row = current($row);
        echo '<td>' . $c_row . '</td>';
        next($row);
        $y = $y + 1;
    }
    echo '</tr>';
    $i = $i + 1;
}
pg_free_result($result);

echo '</table></body></html>';

1 个答案:

答案 0 :(得分:1)

您可以限定表格的名称(SIEM.Maquina222),也可以将架构添加到路径SET search_path = public,SIEM)。

编辑:

见esp。 5.7.3. The Schema Search Path。您可能希望使用ALTER TABLEALTER ROLE

相关问题