简体   繁体   中英

How to select the schema I want from a Postgresql database?

I have two schemas, one called public and another called SIEM. I want to print a table from the SIEM schema, but it is not printing anything. How can I select the schema I want to print a table from?

$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>';

you can either qualify the name of your table ( SIEM.Maquina222 ) or add the schema to your path ( SET search_path = public,SIEM ).

edit:

see esp. 5.7.3. The Schema Search Path . you may want to use ALTER TABLE or ALTER ROLE .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM