Computer >> 컴퓨터 >  >> 프로그램 작성 >> MySQL

MySQL의 모든 데이터베이스를 표시하고 각 데이터베이스에 대해 모든 테이블을 표시하려면 어떻게 해야 합니까?

<시간/>

이를 위해 INFORMATION_SCHEMA를 사용할 수 있습니다. 다음은 구문입니다 -

my_schema.SCHEMA_NAME에서 my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME)을 선택합니다. 

MySQL의 모든 데이터베이스와 각 데이터베이스를 표시하기 위해 위의 구문을 구현해 보겠습니다. -

mysql> information_schema.SCHEMATA에서 my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) 선택 my_schema 왼쪽 조인 information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMAgroup by my_schema.SCHEMA_NAME 

이것은 다음과 같은 출력을 생성합니다 -

+---------------------------+------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------------------ -------------------------------------------------- ----------+| SCHEMA_NAME | group_concat(tbl.TABLE_NAME) |+-----------------------------------------+---------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------+| 둘 다인노드밴드마이삼 | 직원, 학년 데모, 학생, 학생 정보 || 사업 | addconstraintdemo, addonedaydemo, autoincrementtozero, booleandemo, 대학, columnvaluenulldemo, countcolumns, datatoolongdemo, deletedemo, demoemptyandnull, distinctdemo1, employeetable, findandreplacedemo, foreigntabledemo, groupdemo1, indemo, intandbigint20demo, javadatetimedemo, likedemo, modifycolumndemo, multiplerecordwithvalues, nestedtransactiondemo, nulldemo, orderbydemo, primarytable1, randomintegerdemo, retrievefirst40characters, saveintotextfile, selectinwithbetweendemo, sortingdemo, studentrecordwithmyisam, tabledemo3, tblifdemo, textintonumberdemo, trailingandleadingdemo, tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, uniqueconstrainttable, updatewithlimit, variableastablename, adddatetimewithother, agecalculationfromdatetime, autostoredate, chardemo, COLORTABLE, commaseperatedemo, countrycitydemo, datatypedemo, deleterecord, demoindex, dropindex,enumdemo,finddemo,functionindexdemo,groupt_concatdemo,indexingdemo,intandtinyint,keydemo,limitoffsetdemo,수정columnnamedemo,mul tiplerowsinsert,newstudent,nulldemo1,orderdemo,prim || 명령줄 | 대소문자를 구분하지 않는distinctdemo,maxplus1demo 삽입, 강사, 음수 값을 0으로 데모 || 고객 추적기 | 널 || customer_tracker_database | 널 || 고객 추적기 | 널 || 데이터베이스1 | 널 || 데이터베이스 샘플 | 널 || 데모 | 마이테이블 || 교육 | 학생, 대학 || hb_student_tracker | demotable194, demotable202, demotable210, demotable218, demotable227, reorderintegerexcept0, demotable195, demotable203, demotable211, demotable219, demotable228, 학생, demotable196, demotable204, demotable212, demotable220, demotable229, demotable197, demotable205, demotable213, demotable221, demotable230, demotable198, demotable206, demotable214, |demotable223,demotable231,demotable199,demotable207,demotable215,demotable224,demotable232,demotable192,demotable200,demotable208,demotable216,demotable225,demotable233,demotable2901,current2 안녕하세요 | 널 || 정보 스키마 | 열 INNODB_CMP, INNODB_FIELDS, INNODB_FT_INDEX_TABLE, INNODB_TRX, PROCESSLIST, ST_SPATIAL_REFERENCE_SYSTEMS, 뷰 엔진 INNODB_CMP_PER_INDEX, INNODB_FOREIGN, INNODB_INDEXES, INNODB_VIRTUAL, 프로파일 링 STATISTICS, 이벤트 INNODB_CMP_PER_INDEX_RESET, INNODB_FOREIGN_COLS, INNODB_METRICS, KEY_COLUMN_USAGE, REFERENTIAL_CONSTRAINTS, TABLE_CONSTRAINTS, CHARACTER_SETS, 파일 INNODB_CMP_RESET, INNODB_FT_BEING_DELETED, INNODB_TABLES, 키워드 RESOURCE_GROUPS, TABLE_PRIVILEGES, COLLATION_CHARACTER_SET_APPLICABILITY, INNODB_BUFFER_PAGE, INNODB_CMPMEM, INNODB_FT_CONFIG, INNODB_TABLESPACES, OPTIMIZER_TRACE 루틴 테이블, 정렬, INNODB_BUFFER_PAGE_LRU, INNODB_CMPMEM_RESET, INNODB_FT_DEFAULT_STOPWORD, INNODB_TABLESPACES_BRIEF, 파라미터 SCHEMA_PRIVILEGES, TABLESPACES, COLUMN_PRIVILEGES, INNODB_BUFFER_POOL_STATS, INNODB_COLUMNS, INNODB_FT_DELETED, INNODB_TABLESTATS,PARTITIONS,SCHEMATA,TRIGGERS,COLUMN_STATISTICS,INNODB_CACHED_INDEXES,INNODB_DATAFILES,INNODB_FT_INDEX_CACHE,INNODB_TEMP_TABLE_INFO,PLUGINS,ST_GEOMETRY_COLUMNS,USER_PR 마을 || Instant_app | 널 || 자바데이터베이스2 | 널 || 자바샘플 데이터베이스 | 널 || 로그인 | 널 || 마이 비즈니스 | 널 || 마이데이터베이스 | 널 || mysql | db,help_category,mytable,selectdistinct_countdemo,slave_worker_info,time_zone_transition,default_roles,help_keyword,password_history,selectnonnumericvalue,slow_log,time_zone_transition_type,demoyee_information,help_relation,plugin,selectrowdemo,table,user,bug | 기능명,innodb_index_stats,procs_priv,server_cost,tempvariableassignment,columns_priv,general_log,innodb_table_stats,proxys_priv,servers,time_zone,구성 요소,global_grants,aprodemoc,component,global_grants,limitdemo,removenumericcharators,slave_master_info,time_zone_ 일대일 관계 | 널 || 온라인 서점 | 널 || 성능 스키마 | events_errors_summary_by_user_by_error, events_stages_summary_by_user_by_event_name, events_statements_summary_by_digest, events_transactions_history_long, events_waits_history_long, file_summary_by_event_name, memory_summary_by_host_by_event_name, persisted_variables, replication_connection_configuration, session_variables, socket_summary_by_instance, table_lock_waits_summary_by_table, 계정, events_errors_summary_global_by_error, events_stages_summary_global_by_event_name, events_statements_summary_by_host_by_event_name, events_transactions_summary_by_account_by_event_name, events_waits_summary_by_account_by_event_name, file_summary_by_instance, memory_summary_by_thread_by_event_name, prepared_statements_instances, replication_connection_status, setup_actors, status_by_account, 스레드, cond_instances,events_stages_current,events_statements_current,events_statements_summary_by_program,events_transactions_summary_by_host_by_event_name,events_waits_summary_by_host_by_event_name,global_status,memory_summary by_user_by_event_name,re || RDB | 소년 소녀 || 샘플 | accumulateddemo, addtotaltimedemo, autoincrementdemo, backtick_symboldemo, calculateaveragedemo, changecolumnname, columndoesnotexists, contains_capital_letterdemo, countbooleanfielddemo, crc32demo, decimal_demo, deletefrombasetabledemo, demotable10, demotable108, demotable115, demotable122, demotable13, demotable139, demotable146, demotable153, demotable160, demotable168, demotable175, demotable183, demotable190, demotable23, demotable240, demotable248, demotable255, demotable263, demotable28, demotable35, demotable43, demotable50, demotable58, demotable65, demotable72, demotable8, demotable87, demotable94, displayonlydistinctvalue, employeeinformation, excludecertaincolumnsdemo, findinsetdemo, firstweekofmonth, getfileextensiondemo, groupbydemo, idcolumnadd1demo, insert_prevent, javadatedemo, 저장 프로시저로 제한,병합selectdemo,new_viewdemo,old_tabledemo2,orderbyfield,pipeinsertdemo,primarykeydemo,테이블에서 수신 날짜,removeuniquenessconstraint,returndemo,rowsusinglimit,secondtable,selectdistinctdemo,selectrecordsdemo,showsum inlastrowdemo, stoproundi || 샘플 데이터베이스 | 널 || 스키마 샘플 | 널 || 슬롯 게임 | 널 || 시스템 | host_summary_by_file_io, io_by_thread_by_latency, memory_by_user_by_current_bytes, schema_object_overview, session_ssl_status, user_summary, wait_classes_global_by_latency는, $ host_summary_by_statement_latency을 X $ io_global_by_wait_by_bytes를 X, $ PROCESSLIST를 X, $ schema_table_statistics_with_buffer을 X, $ statements_with_temp_tables을 X, $ wait_classes_global_by_latency, host_summary_by_file_io_type, io_global_by_file_by_bytes, memory_global_by_current_bytes, schema_redundant_indexes, statement_analysis, user_summary_by_file_io을 X waits_by_host_by_latency, $ host_summary_by_statement_type을 X $ io_global_by_wait_by_latency를 X, $ ps_digest_95th_percentile_by_avg_us을 X, $ schema_tables_with_full_table_scans을 X $ user_summary를 X, $ waits_by_host_by_latency, host_summary_by_stages, io_global_by_file_by_latency, memory_global_total, schema_table_lock_waits, statements_with_errors_or_warnings, user_summary_by_file_io_type, waits_by_user_by_latency을 X, $ innodb_buffer_stats_by_schema을 X, latest_file_io, X을 $ $를 X ps_digest_avg_latency_distribution,x$session,x$user_summ ary_by_file_io,x$waits_b || 테스트 | absolutedifference, addcolumntocountasserialnumber, addingvaluetoexisting, allnamesstartwithaorborc, appenddatademo, autoincrementtabledemo, bigintdemo, boolorbooleanortinyintdemo, changecurrentautoincrementvalue, collatedemo, comparisononintfield, concatvalues, convertdatedemo, countingdemo, csvformatoutputs, 고객, dateformatdemo, datetimedemo, decimaldemo, defaultdate, demoofvertical, differentrows, duplicaterecords, employeemaxandsecondmaxsalary, equivalentofidentityinmysql, findlowercasevalue, firsttablemaxvalue, getdatefromtimestamp, gettotalhoursdemo, ifnotnulldemo, incrementingdemo1, insertnullvalue, integerdemo, javainsertdemo, likebinarydemo, lowercasedemo, morethan2columnconcat, newstable, notnullatcreationoftable, occurrencesofcharacter, orderbycharacterlength, orderbynullfirstdemo, orlikedemo, populatetabledemo, productdemo, removenullrecordsdemo, renameviewdemo, rowendswithspecificstring, searchtextdemo, select_distincttwocolumns, selectindemo,selecttop2fromeachgroup,세션변수demo,sortcolumnzeroatlastdemo,strin greplacedemo, 학생 정보 || 테스트3 | groupwithtopndemo, productdemo, studentinformation, bestdateformatdemo, lastrecordbeforelastone, radiansdemo, updatestringdemo, bitdemo, mostrecentdatedemo, returnresultofmd5demo, countdemo, mysqlandconditiondemo, select_timestampdemo, deletedemo, nullcasedemo, selectt의 extafterlastslashdemo, differentdatetime, 순서, siglequotesdemo, expandedoutputdemo, orderbydatethentimedemo, singleautoincrementcolumndemo, fieldlessthan5chars, 게시물, storeddemo || 추적기 | 예방음수 || 대학 데이터베이스 | 널 || 웹 | 강등 가능492, 강등 가능500, 강등 가능508, 강등 가능516, Demotable525,demotable533,DemoTable,DemoTable,DemoTable,DemoTable,DemoTable,DemoTable,DemoTable,DemoTable,demotable605,demotable213,select,demotable4621,de demotable267, demotable275, demotable283, demotable291, demotable299, demotable307, demotable315, demotable323, demotable331, demotable339, demotable347, demotable355, demotable363, demotable371, demotable379, demotable388, demotable396, demotable404, demotable412, demotable420, demotable428, demotable436, demotable444, demotable452, demotable460, demotable468, demotable476, demotable493, demotable501, demotable509, demotable517, demotable526, demotable534, DemoTable, DemoTable, DemoTable, DemoTable, DemoTable, DemoTable, DemoTable, DemoTable, demotable606, demotable614, view_demotable388, demotable485, demotabe620, demotable218, demotable226, demotable234, demotable244, demotable252,demotable260,demotable268,demotable276, || web_tracker | 널 || 웹트래커 | NULL |+---------------------------+------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------+36개의 행 세트, 6개의 경고(0.18초)