Sponsored Content
Top Forums Programming Dynamically checking rules in database tables using SQL Post 302846531 by figaro on Saturday 24th of August 2013 12:36:53 PM
Old 08-24-2013
Yes, I was contemplating the export and then an import also. I see that more of a last resort option, because it involves writing to a file together with all its shortcomings.

The other solution we are investigating is through the use of cursors. This looks roughly as follows:
- create a list of all tables in the schema
- loop through these tables to create a list of all columns per table which are not keys
- loop through these columns to pick up rows where all values are NULL

Disadvantage here is that it requires the use of a procedural language as well as being less portable to other database systems.

Are you saying it is impossible to do entirely within MySQL in (possibly nested) SQL statements?
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

writing database tables into a file in unix

I want to collect the database tables(Ex: Emp,Sal,Bonus...etc) in a file & give this file at the command prompt, when prompted for the tables list at command prompt. How can i do that ? Ex:- Import jason/jason1 tables=emp,sal,bonus log=j1.log i want to change this into Ex:- Import... (3 Replies)
Discussion started by: dreams5617
3 Replies

2. Shell Programming and Scripting

Automating back up of database tables

Hi all, i would like to set a cronjob to back up my db tables. I have written the par file, i would like to know how can i execute a exp command in a shell script. my par file userid=admin/password file=backup.dmp log=backupLOG.log tables= (Tables 1, Tables 2)My cron job script will be... (1 Reply)
Discussion started by: new2ss
1 Replies

3. Shell Programming and Scripting

Tables to query to find users for database from shell script

I am coding shell script. I need to connect to different databases like DB2, Oracle and Sybase. I would then need to query tables where it has all the groups, users for that database. I would also need who has what kind of permissions. EG: I know for DB2 some TABAUTH table needs to be... (0 Replies)
Discussion started by: pinnacle
0 Replies

4. Programming

SQL Add to Multiple Tables

I'm pretty new to the database world and I've run into a mental block of sorts. I've been unable to find the answer anywhere. Here's my problem: I have several tables and everything is as normalized as possible (as I've been lead to understand normalization.) Normalization has lead to some... (1 Reply)
Discussion started by: flakblas
1 Replies

5. Shell Programming and Scripting

Passing filename dynamically in SPOOL of SQL*PLUS in shell script

Hi all, I am executing shell script in which I am using SQLLDR In this SQLLDR I am passing text file having PL/SQL script. This script will produce some formated output, this output I have to spool in another text file. Currently I have given this in script file as following Spool... (2 Replies)
Discussion started by: shekharjchandra
2 Replies

6. Programming

Query to join two tables in SQL

Hi, I have 2 tables. Table1 name map_code data_code id aaa 2732C 3333B 10 bbb 1223F 2545v 11 ccc 12 Table2 name map_code data_code id text_description aaa 2732C 3333B 10 description 1 bbb 1223F 2545v 11 ... (3 Replies)
Discussion started by: vanitham
3 Replies

7. Shell Programming and Scripting

Help with database checking script

I haven't coded in ksh in forever and this script is proving me not a great coder. I keep getting unexpected end of file when I try to execute this...Line 94 is the last line of the code.. #!/usr/bin/ksh . /home/oraprod/.bash_profile DBSID=prod # Database sid CONNECTSTR=apps/xxxxxxxx@prod #... (6 Replies)
Discussion started by: kirkladb
6 Replies

8. UNIX for Advanced & Expert Users

Identify tables from Oracle sql scripts

Hi, Please let me know if you have any thoughts on how to read a table that has all the oracle sql files or shell scripts at the job and step level to identify all the tables that does merge, update, delete, insert, create, truncate, alter table (ALTER TABLE XYZ RENAME TO ABC) and call them out... (1 Reply)
Discussion started by: techmoris
1 Replies
Jifty::Script::Schema(3pm)				User Contributed Perl Documentation				Jifty::Script::Schema(3pm)

NAME
Jifty::Script::Schema - Create SQL to update or create your Jifty application's tables SYNOPSIS
jifty schema --setup Creates or updates your application's database tables Options: --print Print SQL, rather than executing commands --setup Upgrade or install the database, creating it if need be --create-database Only creates the database --drop-database Drops the database --ignore-reserved-words Ignore any SQL reserved words in schema definition --no-bootstrap don't run bootstrap --help brief help message --man full documentation DESCRIPTION
Manages your database. options --print Rather than actually running the database create/update/drop commands, Prints the commands to standard output --create-database Send a CREATE DATABASE command. Note that --setup, below, will automatically send a CREATE DATABASE if it needs one. This option is useful if you wish to create the database without creating any tables in it. --drop-database Send a DROP DATABASE command. Use this in conjunction with --setup to wipe and re-install the database. --setup Actually set up your app's tables. This creates the database if need be, and runs any commands needed to bring the tables up to date; these may include CREATE TABLE or ALTER TABLE commands. This option is assumed if the database does not exist, or the database version is not the same as the application's version. --ignore-reserved-words Ignore any SQL reserved words used in table or column definitions, if this option is not used and a reserved word is found it will cause an error. --no-bootstrap don't run Bootstrap, mostly to get rid of creating initial data --help Print a brief help message and exits. --man Prints the manual page and exits. DESCRIPTION
Looks for all model classes of your Jifty application and generates SQL statements to create or update database tables for all of the models. It either prints the SQL to standard output (--print) or actually issues the "CREATE TABLE" or "ALTER TABLE" statements on Jifty's database. (Note that even if you are just displaying the SQL, you need to have correctly configured your Jifty database in ProjectRoot"/etc/config.yml", because the SQL generated may depend on the database type.) By default checks for SQL reserved words in your table names and column definitions, throwing an error if any are found. If you want to permanently turn this behaviour off you can set CheckSchema to 0 in the database section of your applications config file. BUGS
Due to limitations of DBIx::DBSchema, this probably only works with PostgreSQL, MySQL and SQLite. It is possible that some of this functionality should be rolled into Jifty::DBI::SchemaGenerator METHODS
run Prints a help message if the users want it. If not, goes about its business. Sets up the environment, checks current database state, creates or deletes a database as necessary and then creates or updates your models' schema. run_upgrades Take the actions we need in order to bring an existing database up to current. setup_environment Sets up a minimal Jifty environment. schema Returns a Jifty::Schema object. probe_database_existence Probes our database to see if it exists and is up to date. create_all_tables Create all tables for this application's models. Generally, this happens on installation. create_tables_for_models TABLEs Given a list of items that are the scalar names of subclasses of Jifty::Record, either prints SQL or creates all those models in your database. upgrade_jifty_tables Upgrade Jifty's internal tables. upgrade_application_tables Upgrade the application's tables. upgrade_plugin_tables Upgrade the tables for each plugin. upgrade_tables BASECLASS, FROM, TO, [UPGRADECLASS] Given a "BASECLASS" to upgrade, and two version objects, "FROM" and "TO", performs the needed transforms to the database. "UPGRADECLASS", if not specified, defaults to "BASECLASS"::Upgrade manage_database_existence If the user wants the database created, creates the database. If the user wants the old database deleted, does that too. Exits with a return value of 1 if the database drop or create fails. perl v5.14.2 2011-02-10 Jifty::Script::Schema(3pm)
All times are GMT -4. The time now is 01:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy