PDA

View Full Version : Adding a table to a Database



yvonne.milne
2016-03-10, 06:33
Introduction

When you create a Lianja database, e.g. mydatabase, a mydatabase sub-directory is created in the Lianja data directory (default: C:\lianja\data\).

The database catalog,mydatabase.cat, is created in this sub-directory along with its associated memo (mydatabase.cam) and index (mydatabase.cax) files. The database catalog contains information about its tables and their associated files.

When you create a new table in your database in the Data Workspace, see here for the Guide to the Data Workspace video (http://www.lianja.com/doc/index.php/Guide_to_the_Data_Workspace_(Video)), or using the CREATE TABLE (http://www.lianja.com/doc/index.php/CREATE_TABLE) command, the table is created in the database's subdirectory (C:\lianja\data\mydatabase\) and its information is added to the database catalog file.

In the Lianja/VFP Command Window in the App Inspector (http://www.lianja.com/doc/index.php/App_Inspector_(Video)) or the Console workspace you can use any of the following commands to get more information about your open database (use OPEN DATABASE (http://www.lianja.com/doc/index.php/OPEN_DATABASE) if the database is not already open (http://www.lianja.com/doc/index.php/DATABASE())).


dir
list database
list files

Adding a table to a Database

If you have an existing Lianja table, you can also add this to your database. When you add a table to a database, the physical table and its associated files are not moved or copied: the table's information (location, indexes etc.) is added to the database catalog file.

You can add a table to a database in the Data workspace from the Tables Additional Commands (or right-click context menu).

In the example below, the attachments table in the southwind database is added to the mydatabase database.

Note that the attachments table is now in the mydatabase database and can be accessed as normal, but its physical location is still C:\lianja\data\southwind\attachments.dbf.

1260

Similarly, if you drag 'n' drop a table from Windows Explorer to the Tables panel in the Sidebar, the physical location of the table does not change.

1261

These are the equivalent of using the SQL ADD TABLE (http://www.lianja.com/doc/index.php/ADD_TABLE) command.

In the example below, the command:


add table (http://www.lianja.com/doc/index.php/ADD_TABLE) c:\lianja\data\southwind\products

adds the products table to the open mydatabase database but products.dbf is referenced from C:\lianja\data\southwind\products.dbf.

1262

In contrast, in the example above, the command:


copy file (http://www.lianja.com/doc/index.php/COPY_FILE) C:\lianja\data\southwind\employees.* C:\lianja\data\mydatabase\employees.*

physically copies all files from the southwind database directory with the basename employees to their equivalent in the mydatabase database directory.

To add employees to the mydatabase catalog, use the REBUILD DATABASE (http://www.lianja.com/doc/index.php/REBUILD_DATABASE) command.

Similarly, if you physically copy or move the files at the operating system level, you can then use REBUILD DATABASE (http://www.lianja.com/doc/index.php/REBUILD_DATABASE) to update the database catalog.

Deployment

Important: For deployment, the tables must be physically located in the database's directory, so use the COPY FILE (http://www.lianja.com/doc/index.php/COPY_FILE) command or operating system copy/move along with REBUILD DATABASE (http://www.lianja.com/doc/index.php/REBUILD_DATABASE) prior to deployment.

josipradnik
2016-03-10, 07:22
Thank you Yvonne. Educative as always.

Instead of all possible clever questions regarding your post, I'll ask a stupid one:
What are you using for screenshots or editing to get these finger points and arrows?

Josip

yvonne.milne
2016-03-10, 08:33
Hi Josip,

I use Snagit (techsmith.com).

Regards,

Yvonne