|
| 1 | +CREATE VIEW superschema.app_authorized_grants AS |
| 2 | + SELECT |
| 3 | + coalesce(nullif(s[1], ''), 'PUBLIC') as grantee, |
| 4 | + relname as table_name, |
| 5 | + nspname as table_schema, |
| 6 | + string_agg(s[2], ', ') as privileges, |
| 7 | + relkind as table_type |
| 8 | + FROM |
| 9 | + pg_class c |
| 10 | + join pg_namespace n on n.oid = relnamespace |
| 11 | + join pg_roles r on r.oid = relowner, |
| 12 | + unnest(coalesce(relacl::text[], format('{%%s=arwdDxt/%%s}', rolname, rolname)::text[])) acl, |
| 13 | + regexp_split_to_array(acl, '=|/') s |
| 14 | + WHERE (s[1] = 'authenticated' or s[1] is null) and nspname not in ('pg_catalog', 'information_schema', 'pg_toast') |
| 15 | + GROUP BY grantee, table_name, table_schema, relkind |
| 16 | + ORDER BY relkind != 'r', relkind != 'v', relkind != 'm', relkind != 'i', relkind, nspname, relname; |
| 17 | + |
| 18 | +-- AEXPR_OP |
| 19 | +select a = b; |
| 20 | + |
| 21 | +-- AEXPR_OP_ANY |
| 22 | +SELECT foo = ANY(x) FROM vtable; |
| 23 | + |
| 24 | +-- AEXPR_OP_ALL |
| 25 | +SELECT foo = ALL(x) FROM vtable; |
| 26 | + |
| 27 | +-- AEXPR_DISTINCT |
| 28 | +-- AEXPR_NOT_DISTINCT |
| 29 | + |
| 30 | +SELECT foo,bar FROM vtable WHERE foo IS DISTINCT FROM bar; |
| 31 | +SELECT foo,bar FROM vtable WHERE foo IS NOT DISTINCT FROM bar; |
| 32 | + |
| 33 | +SELECT t1.foo,t1.bar,t1.baz |
| 34 | +FROM t1 |
| 35 | +LEFT OUTER JOIN t2 ON ( |
| 36 | + t1.foo IS NOT DISTINCT FROM t2.foo |
| 37 | + AND t1.bar IS NOT DISTINCT FROM t2.bar |
| 38 | + AND t1.baz IS NOT DISTINCT FROM t2.baz |
| 39 | +) |
| 40 | +WHERE ( t2.foo IS NULL ); |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +-- AEXPR_NULLIF |
| 45 | + |
| 46 | +select nullif(null, ''); |
| 47 | + |
| 48 | +-- AEXPR_OF |
| 49 | + |
| 50 | +SELECT x, x IS OF (text) AS is_text FROM q; |
| 51 | +SELECT x, x IS NOT OF (text) AS is_text FROM q; |
| 52 | +SELECT COALESCE(4::domainint4, 7::domainint4) IS OF ( domainint4 ) AS t; |
| 53 | + |
| 54 | +-- AEXPR_IN |
| 55 | + |
| 56 | +SELECT |
| 57 | + value IN (SELECT column_name FROM table_name); |
| 58 | + |
| 59 | +SELECT |
| 60 | + value NOT IN (SELECT column_name FROM table_name); |
| 61 | + |
| 62 | +SELECT customer_id, |
| 63 | + rental_id, |
| 64 | + return_date |
| 65 | +FROM |
| 66 | + rental |
| 67 | +WHERE |
| 68 | + customer_id IN (1, 2) |
| 69 | +ORDER BY |
| 70 | + return_date DESC; |
| 71 | + |
| 72 | + |
| 73 | +SELECT |
| 74 | + customer_id, |
| 75 | + rental_id, |
| 76 | + return_date |
| 77 | +FROM |
| 78 | + rental |
| 79 | +WHERE |
| 80 | + customer_id NOT IN (1, 2); |
| 81 | + |
| 82 | +SELECT |
| 83 | + customer_id, |
| 84 | + rental_id, |
| 85 | + return_date |
| 86 | +FROM |
| 87 | + rental |
| 88 | +WHERE |
| 89 | + customer_id <> 1 |
| 90 | +AND customer_id <> 2; |
| 91 | + |
| 92 | +SELECT * |
| 93 | +FROM Employees |
| 94 | +WHERE name IN ('James John', 'Mercy Bush', 'Kate Joel'); |
| 95 | + |
| 96 | +SELECT * |
| 97 | +FROM Employees |
| 98 | +WHERE name NOT IN ('James John', 'Mercy Bush', 'Kate Joel'); |
| 99 | + |
| 100 | +SELECT customer_id |
| 101 | +FROM rental |
| 102 | +WHERE CAST (return_date AS DATE) = '2005-05-27' |
| 103 | +ORDER BY customer_id; |
| 104 | + |
| 105 | +SELECT |
| 106 | + customer_id, |
| 107 | + first_name, |
| 108 | + last_name |
| 109 | +FROM |
| 110 | + customer |
| 111 | +WHERE |
| 112 | + customer_id IN ( |
| 113 | + SELECT customer_id |
| 114 | + FROM rental |
| 115 | + WHERE CAST (return_date AS DATE) = '2005-05-27' |
| 116 | + ) |
| 117 | +ORDER BY customer_id; |
| 118 | + |
| 119 | +-- AEXPR_LIKE |
| 120 | + |
| 121 | +SELECT * FROM student WHERE name LIKE 'a%'; |
| 122 | +SELECT * FROM student WHERE name NOT LIKE 'a%'; |
| 123 | +SELECT |
| 124 | + 'foo' LIKE 'foo', |
| 125 | + 'foo' LIKE 'f%', |
| 126 | + 'foo' LIKE '_o_', |
| 127 | + 'bar' LIKE 'b_'; |
| 128 | + |
| 129 | +-- AEXPR_ILIKE |
| 130 | + |
| 131 | +SELECT * FROM student WHERE name ILIKE 'a%'; |
| 132 | +SELECT * FROM student WHERE name NOT ILIKE 'a%'; |
| 133 | + |
| 134 | + |
| 135 | +-- AEXPR_SIMILAR |
| 136 | + |
| 137 | +select 'xyz' SIMILAR TO 'xyz'; |
| 138 | +select 'xyz' SIMILAR TO 'x'; |
| 139 | +select 'xyz' SIMILAR TO '%(y|a)%'; |
| 140 | +select 'xyz' SIMILAR TO '(y|z)%'; |
| 141 | + |
| 142 | +select 'xyz' SIMILAR TO 'xyz' ESCAPE 'x'; |
| 143 | +select 'xyz' SIMILAR TO 'x' ESCAPE 'x'; |
| 144 | +select 'xyz' SIMILAR TO '%(y|a)%' ESCAPE 'x'; |
| 145 | +select 'xyz' SIMILAR TO '(y|z)%' ESCAPE 'x'; |
| 146 | + |
| 147 | +select 'xyz' NOT SIMILAR TO 'xyz'; |
| 148 | +select 'xyz' NOT SIMILAR TO 'x'; |
| 149 | +select 'xyz' NOT SIMILAR TO '%(y|a)%'; |
| 150 | +select 'xyz' NOT SIMILAR TO '(y|z)%'; |
| 151 | + |
| 152 | +select 'xyz' NOT SIMILAR TO 'xyz' ESCAPE 'x'; |
| 153 | +select 'xyz' NOT SIMILAR TO 'x' ESCAPE 'x'; |
| 154 | +select 'xyz' NOT SIMILAR TO '%(y|a)%' ESCAPE 'x'; |
| 155 | +select 'xyz' NOT SIMILAR TO '(y|z)%' ESCAPE 'x'; |
| 156 | + |
| 157 | +-- AEXPR_BETWEEN |
| 158 | +-- AEXPR_NOT_BETWEEN |
| 159 | +-- AEXPR_BETWEEN_SYM |
| 160 | +-- AEXPR_NOT_BETWEEN_SYM |
| 161 | + |
| 162 | +select * from generate_series(1,10) as numbers(a) |
| 163 | + where numbers.a between symmetric 6 and 3; |
| 164 | + |
| 165 | +select * from generate_series(1,10) as numbers(a) |
| 166 | + where numbers.a between 6 and 3; |
| 167 | + |
| 168 | +select * from generate_series(1,10) as numbers(a) |
| 169 | + where numbers.a not between symmetric 6 and 3; |
| 170 | + |
| 171 | +select * from generate_series(1,10) as numbers(a) |
| 172 | + where numbers.a not between 6 and 3; |
0 commit comments