MyEclipse Database Tutorial: How to use tables, foreign keys, and indexes

Source: Internet
Author: User

myeclipse Database Tutorial: How to use tables, foreign keys, and indexes

MyEclipse's Database Explorer tool provides a number of wizards and actions to easily create and delete tables, relationships, and indexes. In this tutorial, you will learn to:

    • Creating and deleting tables
    • Creating and deleting foreign keys
    • Creating and deleting indexes

No myeclipse? Download Now

1. Create a new index

Creating an index is an important performance tool for developers, typically creating a table's index key on the DBMS. However, it is often necessary to use an order by or a WHERE clause to enhance performance in other areas. Let's say you may have many customers in City who are ordering, and you can create an index in that area.

(1) Open a connection in the database browser view to build the MyEclipse Derby database.

Verify the established connection

(2) Expand the connection, right-click the Customer table, and select New Index.

(3) Enter CITY_IDX in the Index Name field type and click the Add button to add this new index to the column to which it belongs.

To create a new index

(4) Click the first cell in the index list, click the drop-down arrow, select City, and then click Finish.

Select Index Column

(5) In the Table/object Information view, click the Indexes tab to see the new index.

1.1 Deleting an index
    1. Select the table that contains the index in the database browser.
    2. Click Index options in the table/object Information view.
    3. Right-click the index you want to delete and select Drop Index.
    4. Click OK to confirm.
Delete Index2. Create a new table

During the design process, the developer can apply and create the corresponding database function application pattern table in other application fields, and can persist the application data. Add a new table named Customer_relationship to represent the number of customers that have been associated in some way.

(1) Right-click the table in the database browser and select New table.

(2) The Table Name field type is customer_relationship.

(3) Click the Column option, and then click the Add button to add the table to the column. You want to add a number of two related customers to the ID column.

(4) in the first_cust_id type of the Name field, select Integer from the drop-down type list, select the primary key check box, and click Finish.

adding table columns

(5) Use the same steps to add another column named second_cust_id.

Complete table

(6) Click Finish to create the table. The table appears in the list of tables in the database browser.

2.1 Deleting a table
    1. Right-click the table that you want to delete, and then select Delete table.
    2. Click OK to confirm.
Delete a table3. Create a new foreign key

Now that you have created the Customer_relationship table, both sides reference the foreign key in the new realm to be associated to the CustomerNumber realm of the Customer table. Two customers have an effective relationship, they must be valid customers, which also determines that they need to record through the Customer table.

(1) Right-click Customer_relationship in the Database browser and select the new foreign key.

(2) The Foreign Key Name field type is FIRST_CUST_FK.

(3) Click the first cell in the Foreign key column, click the drop-down arrow, select first_cust_id, and then click Finish.

Add a foreign key

(4) Follow the same steps to create a second foreign key named SECOND_CUST_FK and reference second_cust_id.

(5) In the Table/object Information view, select the index option to view the new foreign key index.

Foreign keys in Index options3.1 deleting foreign keys
    1. In the database browser, select the table that contains the foreign key.
    2. Click the Table/object Information view foreign key option.
    3. Right-click the foreign key that you want to delete, and then select Delete foreign key.
    4. Click OK to confirm.
Delete foreign key

MyEclipse official Chinese online line, welcome to download Communication!

0Useful (1)

MyEclipse Database Tutorial: How to use tables, foreign keys, and indexes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.