How to Use word vb macro to generate SQL

Source: Internet
Author: User

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.

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.