information-schema

How can I get SQL Server column definition with parentheses and everything?

淺唱寂寞╮ 提交于 2019-12-03 16:34:30
I need a smart way to get the data types out of INFORMATION_SCHEMA.COLUMNS in a way that could be used in a CREATE TABLE statement. The problem is the 'extra' fields that need to be understood, such as NUMERIC _ PRECISION and NUMERIC _ SCALE. Obviously, I can ignore the columns for INTEGER (precision of 10 and scale of 0), but there are other types I would be interested in, such as NUMERIC. So without writing lots of code to parse the table, any ideas on how to get a sort of field shorthand out of the column definition? I would like to be able to get something like : int, datetime, money,

Find out if user got permission to select/update/… a table/function/… in PostgreSQL

◇◆丶佛笑我妖孽 提交于 2019-12-03 13:19:19
问题 What is the recommended way to figure out if a user got a certain right (e.g. select or execute) on a certain class (e.g. table or function) in PostgreSQL? At the moment I got something like aclcontains( someColumnWithAclitemArray, makeaclitem(userOid,grantorOid,someRight,false)) but it's terrible since I have to check for every grantorOid that is possible and for every userOid the user can belong to. On a related note: what are the possible rights you can test for? I haven't found any

Query to get all CREATE statements of MySql Tables

寵の児 提交于 2019-12-03 08:04:27
问题 I want All CREATE statements of MySql Tables in 1 query result. For example, INFORMATION_SCHEMA contains all table names,comments etc. but where are the CREATE statements are stored in MySql ? can it be retrieved in one query for all tables ? Currently i am retrieving TABLE ddl as below for 1 table. I have 100's of tables so i can repeat the same everytime which is time taking process show create table row_format; 回答1: mysqldump -h localhost -u root -p --no-data --compact some_db mysqldump -d

Query to get all CREATE statements of MySql Tables

梦想的初衷 提交于 2019-12-02 20:43:26
I want All CREATE statements of MySql Tables in 1 query result. For example, INFORMATION_SCHEMA contains all table names,comments etc. but where are the CREATE statements are stored in MySql ? can it be retrieved in one query for all tables ? Currently i am retrieving TABLE ddl as below for 1 table. I have 100's of tables so i can repeat the same everytime which is time taking process show create table row_format; Praveen Prasannan mysqldump -h localhost -u root -p --no-data --compact some_db mysqldump -d --compact --compatible=mysql323 ${dbname}|egrep -v "(^SET|^/\*\!)" How do I use mysqldump

Mysql inconsistent number of rows count(*) vs table.table_rows in information_schema

让人想犯罪 __ 提交于 2019-12-02 11:40:41
i came across a strange phenomenon, and i hope, that someone can explain this to me: i have a some "static" tables (they change once per day). mysql> select 'appObjectGroups' as tbl, count(*) as num from appObjectGroups union select 'appObjectDependencies' as tbl, count(*) as num from appObjectDependencies union select 'appObjectUrls' as tbl, count(*) as num from appObjectUrls union select 'appObjectValues' as tbl, count(*) as num from appObjectValues union select 'appObjects;' as tbl, count(*) as num from appObjects; +-------------------------+------+ | tbl | num | +-------------------------+

How to get the dimensionality of an ARRAY column?

两盒软妹~` 提交于 2019-12-02 10:41:04
I'm working on a project that collects information about your schema from the database directly. I can get the data_type of the column using information_schema.columns , which will tell me if it's an ARRAY or not. I can also get the underlying type ( integer , bytea etc) of the ARRAY by querying information_schema.element_types as described here: https://www.postgresql.org/docs/9.1/static/infoschema-element-types.html My problem is that I also need to know how many dimensions the array has, whether it is integer[] , or integer[][] for example. Does anyone know of a way to do this? Google isn't

Accessing H2 database schema

孤街醉人 提交于 2019-12-01 22:52:50
问题 Im currently accessing an embedded H2 database in java using jOOQ to generate table classes etc. I can currently execute queries such as create.select().from(TEST).fetch() in my code, return results etc. However I cant query the information schema. I can access it ok using the H2 console, and creating a view for a given information_schema table works fine. My question is how should I be accessing the information_schema eg to perform a query such as SELECT * FROM INFORMATION_SCHEMA.TABLES from

MySQL: How can I get the timestamp of the last insertion to the database

限于喜欢 提交于 2019-12-01 21:33:05
How can I check when was the last time (timestamp) that I wrote in the database, irrespectively of the database table that I inserted into? Turned out to not be the answer (can't delete as accepted). See comments below this answer. I wasn't able to use information_schema.tables update_time as the column wasn't being updated but for create_time this worked. It would work for update_time (if changed) if update_time gets updated which might be true in your setup. select table_schema,table_name,max_time from information_schema.tables t1 JOIN (select MAX(t2.create_time) AS max_time FROM information

Accessing H2 database schema

我怕爱的太早我们不能终老 提交于 2019-12-01 20:55:40
Im currently accessing an embedded H2 database in java using jOOQ to generate table classes etc. I can currently execute queries such as create.select().from(TEST).fetch() in my code, return results etc. However I cant query the information schema. I can access it ok using the H2 console, and creating a view for a given information_schema table works fine. My question is how should I be accessing the information_schema eg to perform a query such as SELECT * FROM INFORMATION_SCHEMA.TABLES from within my java code? Do I have to create a view, can the schema be accessed through jooq-meta or some

Creating a site to query a database of tables

不羁岁月 提交于 2019-12-01 17:21:14
I have a small problem. I am working with some manual testers who are untrained in programming/database design. Our current process means that these manual testers need to insert data into our database at certain times whilst we build a GUI to facilitate this in the future. In the interim, I would like to create a simple site. What I would like to do with the site is, simply, connect to our database, allow the manual tester to enter some keywords, and return any columns within tables that are close/related to the keywords provided. This would save a lot of time for our testers searching for