Lets say I have table of Salary containing columns id,created_on,company,value. From this as value is the sensitive information I do not want that to be audited. How to do this?
I understand we can disable log per table level but i want to understand how can we do that at column level
When querying columns that are a Postgres domain type using JDBC (with driver https://jdbc.postgresql.org/ version 42.3.3), there doesn't seem to be any way of getting the domain information; only the underlying datatype is reported.
create domain account_uuid_type as uuid;
create domain customer_uuid_type as uuid;
create table test (
account_uuid account_uuid_type,
customer_uuid customer_uuid_type
);
insert into test
(account_uuid, customer_uuid)
values
(
'4c1210c2-e785-4462-926c-1789cd1aa88c',
'b155e10c-10cd-4a11-b427-d7c78397b617'
);
When querying the table from Java using select account_uuid, customer_uuid from test, the information from the PgResultSet is that the pgType values for the columns is uuid. There's no mention of the more specific domain information. Is there a way of asking Postgres to add the domain information into the metadata?
I'm using Postgres on AWS RDS. My application is encrypting selected columns in a table using AWS KMS encryption. I tried but could not find a way to configure KMS keys and use the decrypt() in select query.
e.g. my app is encrypting myTable.secureColumnusing KMS. now I'm trying to fire below query:
SELECT *
FROM myTable
WHERE decrypt(secureColumn, 'key', 'aes') = 'data';
I didn't find how to configure KMS keys in pgCrypto and use in above query.
Has anyone tried this?
Thanks in advance.
I have a PostgreSQL server running on beta and one running locally. On both, I have a table called profile with a column named name of type character varying (255). I have checked that the dbs have the same values.
The weird part is when I do a select on the profile table with order by name asc I am getting different results. So on my local db, profile with name (I)Contractor is first and on beta profile with name 3B is first.
So it seems on my local db ( comes before numeric characters and vice versa for beta. Any idea how this is happening? Would the sort rule be different for different versions of Postgresql?
The reason for this behavior probably lies in the fact that the two servers run on two different operating systems (eg. Gnu Linux and MS Windows). The difference in the method of sorting is due to the fact that the collation is provided by operating system. To get the same sort order, you can use collate:
select name from profile order by name collate "C"
See also Different behaviour in “order by” clause: Oracle vs. PostgreSQL.
I am trying to store UUID value into my table using PostgreSQL 9.3 version.
Example:
create table test
(
uno UUID,
name text,
address text
);
insert into test values(1,'abc','xyz');
Note: How to store integer value into UUID type?
The whole point of UUIDs is that they are automatically generated because the algorithm used virtually guarantees that they are unique in your table, your database, or even across databases. UUIDs are stored as 16-byte datums so you really only want to use them when one or more of the following holds true:
You need to store data indefinitely, forever, always.
When you have a highly distributed system of data generation (e.g. INSERTS in a single "system" which is distributed over multiple machines each having their own local database) where central ID generation is not feasible (e.g. a mobile data collection system with limited connectivity, later uploading to a central server).
Certain scenarios in load-balancing, replication, etc.
If one of these cases applies to you, then you are best off using the UUID as a primary key and have it generated automagically:
CREATE TABLE test (
uno uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text,
address text
);
Like this you never have to worry about the UUIDs themselves, it is all done behind the scenes. Your INSERT statement would become:
INSERT INTO test (name, address) VALUES ('abc','xyz') RETURNING uno;
With the RETURNING clause obviously optional if you want to use that to reference related data.
It's not allowed to simply cast an integer into a UUID type. Generally, UUIDs are generated either internally in Postgres (see http://www.postgresql.org/docs/9.3/static/uuid-ossp.html for more detail on ways to do this) or via a client program.
If you just want unique IDs for your table itself, but don't actually need UUIDs (those are geared toward universal uniqueness, across tables and servers, etc.), you can use the serial type, which creates an implicit sequence for you which automatically increments when you INSERT into a table.