Yesterday, BOSS issued a command to allow me to quickly generate SQL statements using word macros, so that we do not need to input a piece of metadata when creating a table. To improve efficiency and save costs:
After receiving the command, I started to do it. I searched for the relevant materials online and watched the video tutorial of vb macro. Finally let me write this program, although a little small, but it feels quite good.
The vb macro here is intended for fixed database data dictionary tables.
Because the code is too long to be taken out, here is the result of running the table style and vb in word:
File Name |
T_Test |
Description |
User information table |
Collation No. |
Field name |
Description |
Data Type |
Length |
Default |
Allow Null Value |
Primary Key |
1 |
Userid |
Primary Key ID |
Integer |
10 |
|
|
√ |
2 |
Username |
User Name |
Varchar |
50 |
Chen |
|
|
3 |
Password |
Password |
Varchar |
30 |
My |
|
|
4 |
Telephone |
User phone number |
Varchar |
20 |
112323 |
|
|
5 |
Address |
User address |
Varchar |
50 |
Sss |
√ |
|
6 |
Discription |
User Introduction |
Varchar |
200 |
Sssss |
√ |
|
8 |
Jjjjjj |
Try it |
Varchar |
122 |
333 |
|
|
7 |
Hhhh |
Try again |
Varchar |
23 |
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copy codeThe Code is as follows:
Create table T_Test (
Userid integer not null,
Username varchar (50) Default 'chen' not null,
Password varchar (30) Default 'my 'not null,
Telephone varchar (20) Default '20140901' not null,
Address varchar (50) Default 'ss ',
Discription varchar (200) Default 'ssss ',
Jjjjj varchar (122) Default '20140901' not null,
Hhhh varchar (23) Default '20140901' NOT NULL
);
Alter table T_Test add
CONSTRAINT PK_T_Test primary key (userid );
Comment on table T_Test is 'user info table ';
Comment on column T_Test.userid is 'Primary key id ';
Comment on column T_Test.username is 'username ';
Comment on column T_Test.password is 'Password ';
Comment on column T_Test.telephone is 'user phone ';
Comment on column T_Test.Address is 'user address ';
Comment on column T_Test.Discription is 'user introduction ';
Comment on column T_Test.jjjjjj is '';
Comment on column T_Test.hhhh is 'try Za ';
It is good to run it again in pl/SQL, and it can be executed directly.