The PowerDesigner set table primary key is automatically grown.

Source: Internet
Author: User
Tags powerdesigner

PowerDesigner Version 12.5

Create a table without saying it. The following is an introduction to setting up automatic growth columns.

1 is created on the columns of the table view.
Double-click the table view to open ——— >columens,
Double-click the column you want to set (the button that displays the ordinal of the column, and the horizontal black arrow appears when clicked).
Open the Column Properties dialog box.

At the bottom of the ' general ' item, find the Sequence dropdown box, with three buttons on ' Create ', ' select ', ' Properties '.

New words click ' Create ' to open the Sequence Properties dialog box, General's name, code arbitrarily modify
Switch to physical options and enter the following items
Start with 1
Increment by 1
MinValue 1
MaxValue decide whether to set it according to your own needs. If not, select No max value
No cache tick

When you have finished typing, click Apply. Created complete. You can see the corresponding creation code in the preview
Also, in the creation code of the table Properties ——— >preview, the creation code of the trigger trigger is automatically added.
Create complete.

Use:

Copy the creation code of the table in the table properties ——— >preview and copy it to Plsql.


Tips:

I don't know if it's my powerdesigner setup or what's going on, the creation Code for table does not automatically join the sequence section.
So, in the sequence properties ——— >preview, copy the sequence creation code into the table-created code
Put it on the Cteate table .... and create Trigger ... Middle


For example:
CREATE TABLE G_ec_lotterycategory (
The lcId number (3) is not NULL,
Lcname NVARCHAR2 (30),
Lcabbr NVARCHAR2 (20),
Constraint Pk_g_ec_lotterycategory primary KEY (LCID)
)
/

Create sequence Sequence_lotcateid
Increment by 1
Start with 1
Nomaxvalue
MinValue 1
NoCache;


Create Trigger tib_g_ec_lotterycategory before insert
On g_ec_lotterycategory for each row
Declare
Integrity_error exception;
errno integer;
ErrMsg char (200);
Dummy integer;
Found Boolean;

Begin
--Column lcId uses sequence Sequence_lotcateid
Select Sequence_lotcateid.nextval INTO:new.lcId from dual;

--Errors handling
exception
When Integrity_error Then
Raise_application_error (errno, errmsg);
End
/
Executes the upper code in Plsql. Create a table;
Add record test;
Insert into G_ec_lotterycategory (LCNAME,LCABBR) VALUES (' 1 ', ' 1 ');
Insert into G_ec_lotterycategory (LCNAME,LCABBR) VALUES (' 2 ', ' 2 ');

After the query, the ID column that you see is automatically growing.

2 Create first, then select in the column's sequence item.
In the tree on the left of PowerDesigner, there is sequence in the submenu of your model item, right click on--> new
Open the Sequence Properties dialog box and add the same method as above.
After the field, or into the table view, double-click the column name to open the Columns Properties dialog box.
General--> sequence Drop-down box appears in the sequence just created, select, save.

The above approach applies to Oracle databases.


If you are creating a MySQL database model, open Table properties, select Columens Double-click, in the ' General ' item, there is an identity check box, tick.



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: info-contact@alibabacloud.com 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.