Select count (*) from user_tab_columns where table_name = upper ('legalentity ')
Foreign key in MySQL:
/* ===================================================== ======================================= */
/* DBMS name: MySQL 4.0 */
/* Created on: 16:38:37 */
/* ===================================================== ======================================= */
Drop table if exists article;
Drop table if exists Board;
Drop table if exists user;
/* ===================================================== ======================================= */
/* Table: Article */
/* ===================================================== ======================================= */
Create table Article
(
Id int not null primary key,
Parent_id int,
Index (parent_id ),
Foreign key (parent_id) references Article (id ),
Board_id int not null,
Index (board_id ),
Foreign key (board_id) references Board (id ),
Article_type int not null,
Title varchar (255) not null,
Body text,
Create_by int not null,
Index (create_by ),
Foreign key (create_by) references User (id ),
Create_time datetime not null,
Hits int not null,
Bytes int,
Last_update_by int not null,
Index (last_update_by ),
Foreign key (last_update_by) references User (id ),
Last_update_time datetime not null,
)
Type = InnoDB;
/* ===================================================== ======================================= */
/* Table: Board */
/* ===================================================== ======================================= */
Create table Board
(
Id int not null primary key,
Create_by int not null,
Index (create_by ),
Foreign key (create_by) references User (id ),
Parent_id int,
Index (parent_id ),
Foreign key (parent_id) references Board (id ),
Name varchar (50) not null,
Remark varchar (255 ),
Create_time datetime not null,
)
Type = InnoDB;
/* ===================================================== ======================================= */
/* Table: User */
/* ===================================================== ======================================= */
Create table User
(
Id int not null primary key,
Name varchar (50) not null,
PWD varchar (50) not null,
)
Type = InnoDB;