Skip to content

Instantly share code, notes, and snippets.

@SupertigerDev
Last active October 14, 2023 10:01
Show Gist options
  • Save SupertigerDev/1d85223d1bbbd6769be2d53297a154c4 to your computer and use it in GitHub Desktop.
Save SupertigerDev/1d85223d1bbbd6769be2d53297a154c4 to your computer and use it in GitHub Desktop.
Postgress bitwise

postgres bitwise add permission

Create the table

CREATE TABLE test (
	id serial PRIMARY KEY,
	perm INT NOT NULL
);

Insert a new row

INSERT INTO test (perm)
VALUES(0);

Bitwise add permission.

UPDATE test
SET perm = perm | 2
WHERE id = 1;

Print the result

SELECT * FROM test
WHERE id = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment