information-schema

Showing MYSQL table columns with key types and reference

蹲街弑〆低调 提交于 2019-12-12 12:45:38
问题 I need a query (INFORMATION_SCHEMA) which will for given schema and table name show me all table columns with following attributes (what key type it is: PK=>Primary Key, UQ=>Unique Key, FK=>Foreign Key, what is key name, and if it is Foreign Key what schema.table.column is referenced): COLUMN_NAME | DATA_TYPE | KEY_TYPE | KEY_NAME | REFERENCED ============+===========+==========+=============+======================== empid | int | PK | PRIMARY | empname | varchar | UQ | uq_empname | empactive

In-built database “information_schema” not logging the last update time of a table in user created database

落花浮王杯 提交于 2019-12-12 04:46:36
问题 The tables table of the in-built database information_schema does not log the activities of the tables in user created databases as the fields table_schema and table_name lacks the values of the user created databases and table names respectively, disallowing me to run the SQL query SELECT update_time FROM information_schema.tables WHERE table_schema='my_db' and table_name='my_table'; -- For table named 'my_table' in database 'my_db' for retrieving last update time (or changed time) of a

Suggestions on storing view meta in SQL Server 2008

↘锁芯ラ 提交于 2019-12-11 11:09:34
问题 I want to store the view meta info like on which tables & columns & queries its created etc, into another mapping table,so that I can reproduce them later point of time. Right now I have a structure like this - CREATE TABLE [dbo].[MAPPING_VIEW] ( [ID] [int] NOT NULL, [OLD_VIEW] [varchar](40) NULL, [NEW_VIEW] [varchar](40) NULL, CONSTRAINT [PK_MAPPING_VIEW] PRIMARY KEY CLUSTERED ([ID] ASC) ) CREATE TABLE [dbo].[MAPPING_VIEW_TBL] ( [ID] [int] NULL, [PARENT_ID] [int] NULL, [OLD_TBL] [varchar](40

mysql get column name when column value matches constraint

≡放荡痞女 提交于 2019-12-11 05:42:02
问题 I'm trying to get column names from a table. I want to supply the row id and I want only the column names for which the value of that column for the specific row (identified by the id) is "true" (my table has a bunch of boolean fields). I want something like: SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME.value = true AND TABLE_THE_COLUMN_IS_FROM.id = "some_id" Where .value would be variable, basically checking each column to see if it were true. I know I can just get

PostgreSQL: union of several tables using dynamic names

被刻印的时光 ゝ 提交于 2019-12-11 03:42:10
问题 I have a set of tables (about 100) in schema named qgep and which names start with vl_ . They have all the same columns (colA, colB, colC). What I'd like to do is to get one big table which is the union of all my vl_* tables, with also a column with the name of the original table. I could get the list of the tables: SELECT table_name FROM information_schema.tables WHERE table_schema = 'qgep' AND table_name LIKE 'vl_%' The only way I found to solve my problem is to generate a SQL command to

get privileges on information_schema mysql

家住魔仙堡 提交于 2019-12-11 01:45:52
问题 If I open MySQL Administrator and I try to delete one event from the table events of the database information_schema I get this error: Access denied for user 'root'@'localhost' to database 'information_schema' What privileges do I need? 回答1: The information_schema tables are all read only, there is no way to delete any rows there. To drop an event, use the DROP EVENT statement. 来源: https://stackoverflow.com/questions/13588002/get-privileges-on-information-schema-mysql

mysql event doesn't work

浪子不回头ぞ 提交于 2019-12-10 20:48:56
问题 Hi I have this event stored in the event table of the information schema: event_catalog:def event_schema: m4af event_name:aggiornaGiorni definer:root@localhost timezone:system event_body:sql event_definition:update m4af.utentibloccati set giorni=giorni+1 event_type:recurring execute at: null interval_value:1 interval_field:day sql_mode:STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION starts:2012-11-26 11:40:41 ends:null status:enabled on_completion:not preserve created:2012-11

MySql select all tables with multiple specific columns

孤人 提交于 2019-12-10 18:06:31
问题 I want to get all table names which has 3 specific columns. What I want is from information schema I want to get all table names which contains columnA AND columnB AND columnC . Currently I am using a query like SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='columnA' AND TABLE_SCHEMA='mysampledatabase'; How can I extend the above query and select tables which contains column names columnA and columnB ? I came across this answer and other similar answers. They

Constraint detail from information_schema (on update cascade, on delete restrict)

跟風遠走 提交于 2019-12-10 16:49:49
问题 Almost all the information I had needed about a database, I could find in information_schema This time I needed to read details of all foreign keys in a database through single query I found every thing in information_schema.key_Column_usage but could not find the constraints like on delete, on update I could do show create table for all individual tables. But is there any way to get these details through some select query like this? SELECT CONSTRAINT_NAME, TABLE_NAME,COLUMN_NAME, REFERENCED

Table design for user's information as well as login credentials?

為{幸葍}努か 提交于 2019-12-10 02:08:01
问题 Initially I would like to ask you to forget about hashing passwords or w/e related to passwords, this question is not related to securing passwords, etc and I do know/understand how this should be done. What is the best approach to store the data in question, considering performance on read/write - to build one or more tables? Single table, for example: Table users: id, username, password, hash, email, group, access, address, phone, parents, ts_created, ts_update Multiple tables, for example: