Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quickshiftin/mysql-inspectors
A set of stored procedures and functions encapsulating schema inspection via information_schema.
https://github.com/quickshiftin/mysql-inspectors
information-schema inspection mysql
Last synced: 14 days ago
JSON representation
A set of stored procedures and functions encapsulating schema inspection via information_schema.
- Host: GitHub
- URL: https://github.com/quickshiftin/mysql-inspectors
- Owner: quickshiftin
- Created: 2012-06-02T22:11:47.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-12-11T02:01:25.000Z (almost 7 years ago)
- Last Synced: 2023-04-21T11:56:37.635Z (over 1 year ago)
- Topics: information-schema, inspection, mysql
- Language: Shell
- Size: 8.79 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
mysql-inspectors
================A set of stored procedures and functions encapsulating schema inspection via information_schema.
dbsWithField
----------------------------------------------------------------
Get a list of databases that have field on any table with a given name.### VARCHAR(1000) dbsWithField(fieldName CHAR(255))
select dbsWithField('product_id');
+-------------------------------------------------------------+
| dbsWithField('product_id') |
+-------------------------------------------------------------+
| trophies, customwear, pq_admin, curious, mysql, media_magic |
+-------------------------------------------------------------+tablesWithField
------------------------------------------------------------------------------------------
Get a list of talbes in a given database that have a field with a given name.### VARCHAR(1000) tablesWithField(fieldName CHAR(255), dbName CHAR(255))
select tablesWithField('product_id', 'trophies');
+-------------------------------------------------------------+
| tablesWithField('product_id', 'trophies') |
+-------------------------------------------------------------+
| coupon_product, order_product, product, product_description |
+-------------------------------------------------------------+fieldExists
---------------------------------------------------------------------------------------------------
Search for existence of a given field on a given table in a given database.### BOOLEAN fieldExists(fieldName CHAR(255), tableName CHAR(255), dbName CHAR(255))
select fieldExists('product_id', 'coupon_product', 'trophies');
+--------------------------------------------------------+
| fieldExists('product_id', 'coupon_product', 'trohies') |
+--------------------------------------------------------+
| 1 |
+--------------------------------------------------------+Installation
------------------------------
The stored procedures and functions need to go somewhere. You might like to create one just
for them like __inpsectors__ or something.One thing you should note, the last parameter on fieldExists is optional. If installed on the
database on which it is run, fieldExists will check the value of database(), in that case you
can pass NULL for the value.At any rate all you need to do is run the install.sql script on the database of your choice;
mysql -u admin -p -D inspectors < install.sql