Is there a way to recreate an empty table structure from .CDX file alone, and possibly export it as SQL commands (CREATE TABLE)? - visual-foxpro

I was tasked to convert some old software that was made using Visual FoxPro, but I was given only some .CDX files. I have access to a VFP program (version 9) but I know nothing about dbf, cdx, etc. It seems that the program "imports" the .CDX all right, but I can't even find a way to see their content.
What I tried so far:
SET INDEX TO S:\mail.cdx
Then I tried:
ATAGINFO(B, S:\mail.cdx)
that I found here and there, but nothing.
It seems to me that the learning curve here is very steep, because even the terminology I found is totally different both from SQL and noSQL databases. Some help here would be highly appreciated.

.CDX files only have the indices, so you won't find all the fields there; ideally, you should be given the .DBF files, and a .DBC file if it exists.
Even if you get those files, though, you'll still only have the fields and indices. What you really need is the Foxpro source code for the software.

Related

Can we find a table that is used in a set of FMBs without opening it individually in Oracle Forms?

I am using both Oracle Forms version 11g and 12c.
Is it possible to find a table for e.g table1 used in the Oracle Forms application screens including LOV's without opening each FMB individually and searching in it.
Totally there are around 50-75 FMBs in the application.
Thanks
While Forms was a new software product, back then in its 3.0 version (or even lower), you could choose whether you'll keep the form source
in the database or
in that case, you could have written a query which selects data from the data dictionary and - hopefully - extract tables' names
in file system
file extension was .INP (not .FMB) and it was a textual file; it means that you could even create a form using text editor! Nobody probably did that, but hey - you could have done it.
.FMB is no longer textual file. Yes, you can open it it a text editor (such as Notepad++) and search for e.g. FROM (because any table used in form's PL/SQL units or LoVs is part of a SELECT statement which requires the FROM keyword) and get something like this:
Yes, you'll get "duplicates" if any table is referenced more than once.
Another option is to write a program which will parse the .FMB file and extract tables' names (I can't help with that, though).

Where to store table version

Where's the best place to store the version of a table in Oracle? Is it possible to store the version in the table itself, e. g. similar to the comment assigned to a table?
I don't think you can store that information in Oracle, except maybe in a comment on the table, but that would be error prone.
But personally I think you shouldn't want to keep track of versions of tables. After all, to get from a version 1 to a version 2, you may need to modify data as well, or other objects like triggers and procedures that use to new version of the table.
So in a way, it's better to version the entire database, so you can 'combine' multiple changes in one atomic version number.
There are different approaches to this, and different tools that can help you with that. I think Oracle even has some built-in feature, but with Oracle, that means that you will be charged gold bars if you use it, so I won't get into that, and just describe the two that I have tried:
Been there, done that: saving schema structure in Git
At some point we wanted to save our database changes in GitHub, where our other source is too.
We've been using Red Gate Source Control for Oracle (and Schema Compare, a similar tool), and have been looking into other similar tools as well. These tools use version control like Git to keep the latest structure of the database, and it can help you get your changes from your development database to scripts folder or VCS, and it can generate migration scripts for you.
Personally I'm not a big fan, because those tools and scripts focus only on the structure of the database (like you would with versioning individual tables). You'd still need to know how to get from version 1 to version 2, and sometimes only adding a column isn't enough; you need to migrate your data too. This isn't covered properly by tools like this.
In addition, I thought they were overall quite expensive for the work that they do, they don't work as easy as promised on the box, and you'd need different tools for different databases.
Working with migrations
A better solution would be to have migration script. You just make a script to get your database from version 1 to version 2, and another script to get it from version 2 to version 3. These migrations can be about table structure, object modifications, or even just data, it doesn't matter. All you need to do is remember which script was executed last, and execute all versions after that.
Executing migrations can be done by hand, or you can simply script it. But there are tools for this as well. One of them is Flyway, a free tool (paid pro support should you need it) that does exactly this. You can feed it SQL scripts from a folder, which are sorted and executed in order. Each script is a 'version'. Meta data about the process is stored in a separate table in your database. The whole process is described in more detail on Flyway's website.
The advantage of this tool is that it's really simple and flexible, because you just write the migration scripts yourself. All the tool does is execute them and keep track of it. And it can do it for all kinds of databases, so you can introduce the same flow for each database you have.
One way is to define a comment on the table:
comment on table your_table is 'some comment';
Then you can read that meta information using all_tab_comments table.
See
How to get table comments via SQL in Oracle?
For further reading, see:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4009.htm

How to get backup from from a very populated table using SQLDEVELOPER

I have a table containing more than 6,000,000 records. When I use the export feature of SQLDEVLPER to get backup, SQLDEVELOPER generates a sql files as big as 8GB which I cannot open it in the SQLDEVELOPER or Notepad or ... because it makes the memory full!
Please guide me know how I can divide it to smaller parts?
Regards
Forget notepad for anything but the most basic editing on small files. You should look into a file viewer/editor that is designed for large files. For viewing very large files, I've had great success with the V File Viewer . For editing, I often use Textpad, but I don't usually open a file this big for editing, just viewing.
It also begs the question WHY you are opening the entire file, as you can just do a "more" on the file (or "less" in linux) to have a peek (check format maybe). It should also be said that a DBA should be doing backups (rman or data pump maybe) of any production data, but anyway.

load data into text file from oracle database views

I want to load data into text file that is generated after executing "views" in Oracle?How can I achieve this in oracle using UNIX.for example-
I want the same in Oracle on unix box.Please help me out as it alredy cosume lots of time.
your early response is highly appreciated!!
As Thomas asked, we need to know what you are doing with the "flat file". For example, if you're loading it into spreadsheet or doing some other processing that expects a defined format, then you need to use SQL*Plus and spool to a file. If you're looking to save a table (data + table definition) for moving it to another Oracle database then EXP/IMP is the tool to use.
We generally describe the data retrieval process as "selecting" from a table/view, not "executing" a table/view.
If you have access to directories on the database server, and authority to create "Directory" objects in Oracle, then you have lots of options.
For example, you can use the UTL_FILE package (part of the PL/SQL built-ins) to read or write files at the operating system level.
Or use the "external table" functionality to define objects that look like single tables to Oracle but are actually flat files at the OS level. Well documented in the Oracle docs.
Also, for one-time tasks, most of the tools for working SQL and PL/SQL provide facilities for moving data to and from the database. In the Windows environment, Toad's good at that. So is Oracle's free SQLDeveloper, which runs on many platforms. You wouldn't want to use those for a process that runs every day, but they're fine for single moves. I've generally found these easier to use than SQLPlus spooling, but that's a primitive version of the same functionality.
As stated by others, we need to know a bit more about what you're trying to do.

Eliminate sort order on Data tab of SQL Developer table view

In Oracle SQL Developer, one can list the data in a table using the Data tab when viewing a table. There is also a 'Sort...' button to set the sort order of the data you are viewing. This can be very handy for viewing some data on the fly.
The problem: I set a sort order for viewing a particular table which is not supported by the indexes on that table. It seems that SQL Developer does the sort on the fly when you go to view that data. At first the delay wasn't too bad. But the table has grown and now it takes forever. There is no way to stop it except by force quitting SQL Developer, losing anything unsaved. (If you know another way to stop this sort, let me know!) So, I should change the viewing sort order to something else, but you can only access the Sort... button when viewing the data.
Is there another way to delete the viewing sort order besides viewing the data?
Where does SQL Developer store this information?
Any way to stop the sorting of the data after clicking on the data tab while waiting for it to appear?
Easy to fix (at least in v1.5.5, which is what I'm using). There's a prefs option to reset it, read about it here:
https://forums.oracle.com/forums/thread.jspa?threadID=860431
Go to Tools > Preferences > Database > ObjectViewer Parameters and select the Clear button. This will clear the sort settings.
I haven't found a command from the GUI to eliminate the sort order but you can use this workaround:
Go in the sqldeveloper settings folder. On M$ Windows is located in %HOME_USER%/Application Data/SQL Developer
Perform a full text search specifying the name of the sorted column. If the column's name is too common (ex: data) specify another column with a different name in the same table. You will find one or more xml files matching your searching criteria. Those files are table descriptors.
At the end of the xml descriptor search for the taf element with name 'orderByClause'. If it contains the name of the column you want eliminate from sorting replace the line with an empty element ()
Restart sqldeveloper and ... sort is not there anymore!
Hope this helps
Cheers,
Fabrizio Fortino
If you are willing to take a little risk, you can follow start by doing Fabrizio's suggestion, and then clean house as follows:
Go in the sqldeveloper settings folder. On M$ Windows is located in %HOME_USER%/Application Data/SQL Developer
Perform a search using the following mask "*tablesettings.xml".
Delete the files that were returned to you.
Restart sqldeveloper and your problem is gone.
To be safe, you might want to just move those files to a quarantine directory.
I believe there isn't currently a way, but there is a suggested enhancement not to retain the filter between sessions that you can vote on here on the SQL Developer forum
Go in the sqldeveloper settings folder. On M$ Windows is located in %HOME_USER%/Application Data/SQL Developer
On SQLDEveloper Version 3.0.03 (and up I guess) search for *GridSettings.xml
Find the file containing xml related to your table/view.
Either delete the file or remove only the lines corresponding to the columns previously deleted from the table. You need to remove lines from ; ;
You don't need to restart sqldeveloper. Just disconnecting and connectting back did it for me.

Resources