SQL statement used to query the number of columns in a table:

Source: Internet
Author: User

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;

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.