资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

mysql怎么查看主表 查看mysql中的表

mysql怎么查看表结构和注释

MySQL 查看表结构简单命令。

10年积累的成都网站建设、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有阿拉尔免费网站建设让你可以放心的选择与我们合作。

一、简单描述表结构,字段类型desc tabl_name;

显示表结构,字段类型,主键,是否为空等属性,但不显示外键。

二、查询表中列的注释信息

select * from information_schema.columns where table_schema = 'db' #表所在数据库

and table_name = 'tablename' ; #你要查的表

三、只查询列名和注释

select column_name,

column_comment from information_schema.columns where table_schema ='db' and

table_name = 'tablename' ;

四、#查看表的注释

select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'

ps:二~四是在元数据表中查看,我在实际操作中,常常不灵光,不知为什么,有了解的大侠请留印。

五、查看表生成的DDL show create table table_name;

mysql 如何判断一个表是主表还是从表

--books表中有字段有bId,pId等字段。

--another有bId,pId等字段(create table another select bId,pid,bAuthor from books;--相关字段以及内容来自books表)。

--books和publising建立外键,参照publishing中的id字段。

alter table books add constraint FK_books_publishing foreign key (pid) references publishing (id) on update cascade;

--another和publishing之间创建外键,参照publishing中的id字段。

alter table another add constraint FK_another_publishing foreign key (pId) references publishing (id) on update cascade;

--举个简单的更新列子:

update publishing set id = 17,pname = '爱好者' where id='14';

--当执行这条语句时(更新publishing表),books表和another表同时进行更新。

--主表更新字段数据等,副表也随之更新,从上面可以看出,主表是publishing,副表是books和another。

--希望能帮到你

mysql 根据子表数量查询主表

select A.* from A join B on A.F_id=B.F_id where B.amount5;

后面的判断条件根据你自己的表来写。

mysql怎么用一条语录查询出主从表 比如有user表,字段有userid userinfoid,

联合查询

select userinfo.userinfoid,username, userage  from user join userinfo on user.userinfoid = userinfor.userinfoid


文章名称:mysql怎么查看主表 查看mysql中的表
本文链接:http://cdkjz.cn/article/dophodp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220