Results 1 to 3 of 3

Thread: Adding a table to a Database

  1. #1
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,840

    Adding a table to a Database

    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, or using the 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 or the Console workspace you can use any of the following commands to get more information about your open database (use OPEN DATABASE if the database is not already open).

    Code:
    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.

    Name:  additionalCommandsAdd.jpg
Views: 582
Size:  82.1 KB

    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.

    Name:  dragFromExplorer.jpg
Views: 641
Size:  90.5 KB

    These are the equivalent of using the SQL ADD TABLE command.

    In the example below, the command:

    Code:
    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.

    Name:  commandLine.jpg
Views: 632
Size:  69.3 KB

    In contrast, in the example above, the command:

    Code:
    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 command.

    Similarly, if you physically copy or move the files at the operating system level, you can then use 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 command or operating system copy/move along with REBUILD DATABASE prior to deployment.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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
    Last edited by josipradnik; 2016-03-10 at 06:32.

  3. #3
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,840
    Hi Josip,

    I use Snagit (techsmith.com).

    Regards,

    Yvonne

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us