新聞中心
數(shù)據(jù)庫(kù)是一種非常重要的數(shù)據(jù)管理工具,很多企業(yè)都會(huì)使用數(shù)據(jù)庫(kù)來(lái)管理企業(yè)的數(shù)據(jù),提高數(shù)據(jù)的存儲(chǔ)和管理效率。在使用數(shù)據(jù)庫(kù)的過(guò)程中,經(jīng)常需要進(jìn)行「切換」操作,例如切換數(shù)據(jù)庫(kù)、表、模式等等。本文將介紹在使用數(shù)據(jù)庫(kù)的過(guò)程中如何進(jìn)行「切換」操作。

公司主營(yíng)業(yè)務(wù):網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。成都創(chuàng)新互聯(lián)推出澤普免費(fèi)做網(wǎng)站回饋大家。
一、切換數(shù)據(jù)庫(kù)
在使用數(shù)據(jù)庫(kù)的過(guò)程中,往往會(huì)有多個(gè)數(shù)據(jù)庫(kù)存在,需要進(jìn)行切換。下面以MySQL數(shù)據(jù)庫(kù)為例,介紹如何切換數(shù)據(jù)庫(kù)。
1. 查看當(dāng)前所在數(shù)據(jù)庫(kù)
使用命令SHOW DATABASES;可以查看當(dāng)前所有的數(shù)據(jù)庫(kù)。使用命令SELECT DATABASE();可以查看當(dāng)前所在的數(shù)據(jù)庫(kù)。例如:
mysql> SHOW DATABASES;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| test |
| world |
+——————–+
7 rows in set (0.00 sec)
mysql> SELECT DATABASE();
+————+
| DATABASE() |
+————+
| NULL |
+————+
1 row in set (0.00 sec)
2. 切換數(shù)據(jù)庫(kù)
使用命令USE DATABASE_NAME; 可以切換到指定的數(shù)據(jù)庫(kù)。例如:
mysql> USE world;
Database changed
使用命令SELECT DATABASE();可以查看切換后的數(shù)據(jù)庫(kù)。
二、切換表
在數(shù)據(jù)庫(kù)中,一個(gè)數(shù)據(jù)庫(kù)往往包含多個(gè)表。在切換表的時(shí)候,需要注意匯總表可能會(huì)產(chǎn)生數(shù)據(jù)誤操作。
1. 查看當(dāng)前所在的表
使用命令SHOW TABLES;可以查看當(dāng)前所有的表。例如:
mysql> SHOW TABLES;
+——————-+
| Tables_in_test |
+——————-+
| mysql_test_table |
| student |
| student_course |
| test_table |
| users |
+——————-+
5 rows in set (0.00 sec)
使用命令SELECT * FROM table_name;即使用一個(gè)SELECT語(yǔ)句來(lái)查看當(dāng)前表的全部數(shù)據(jù)。例如:
mysql> SELECT * FROM users;
+—-+————+———-+———————+
| id | name | password | eml |
+—-+————+———-+———————+
| 1 | test_user1 | 123456 | test_user1@qq.com |
| 2 | test_user2 | 123456 | test_user2@qq.com |
| 3 | test_user3 | 123456 | test_user3@qq.com |
| 4 | test_user4 | 123456 | test_user4@qq.com |
| 5 | test_user5 | 123456 | test_user5@qq.com |
+—-+————+———-+———————+
5 rows in set (0.00 sec)
2. 切換表
使用命令USE DATABASE_NAME; 可以切換到指定的表,例如:
mysql> SELECT * FROM users;
+—-+————+———-+———————+
| id | name | password | eml |
+—-+————+———-+———————+
| 1 | test_user1 | 123456 | test_user1@qq.com |
| 2 | test_user2 | 123456 | test_user2@qq.com |
| 3 | test_user3 | 123456 | test_user3@qq.com |
| 4 | test_user4 | 123456 | test_user4@qq.com |
| 5 | test_user5 | 123456 | test_user5@qq.com |
+—-+————+———-+———————+
5 rows in set (0.00 sec)
mysql> USE test;
Database changed
mysql> SHOW TABLES;
+——————-+
| Tables_in_test |
+——————-+
| mysql_test_table |
| student |
| student_course |
| test_table |
| users |
+——————-+
5 rows in set (0.00 sec)
mysql> USE users;
Database changed
mysql> SELECT * FROM users;
+—-+————+———-+———————+
| id | name | password | eml |
+—-+————+———-+———————+
| 1 | test_user1 | 123456 | test_user1@qq.com |
| 2 | test_user2 | 123456 | test_user2@qq.com |
| 3 | test_user3 | 123456 | test_user3@qq.com |
| 4 | test_user4 | 123456 | test_user4@qq.com |
| 5 | test_user5 | 123456 | test_user5@qq.com |
+—-+————+———-+———————+
5 rows in set (0.00 sec)
三、切換模式
在數(shù)據(jù)庫(kù)中,一個(gè)模式往往包含多個(gè)對(duì)象,例如表、視圖、存儲(chǔ)過(guò)程等等。在切換模式時(shí),需要明確要切換到哪一個(gè)模式下面執(zhí)行操作。
1. 查看當(dāng)前所在模式
使用命令SHOW TABLES; 可以查看當(dāng)前模式下的所有對(duì)象。例如:
mysql> SHOW TABLES;
+——————-+
| Tables_in_test |
+——————-+
| mysql_test_table |
| student |
| student_course |
| test_table |
| users |
+——————-+
5 rows in set (0.00 sec)
2. 切換模式
使用命令USE DATABASE_NAME; 可以切換到指定的模式,例如:
mysql> USE information_schema;
Database changed
mysql> SHOW TABLES;
+————————————+
| Tables_in_information_schema |
+————————————+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY|
| COLUMN_PRIVILEGES |
| COLUMNS |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_COLUMN_USAGE |
| PARAMETERS |
| PARTITIONS |
| PLUGINS |
| PROCESSLIST |
| PROFILING |
| REFERENTIAL_CONSTRNTS |
| RESOURCE_GROUPS |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| SESSION_STATUS |
| SESSION_VARIABLES |
| STATISTICS |
| TABLES |
| TABLESPACES |
| TABLE_CONSTRNTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
+————————————+
32 rows in set (0.00 sec)
mysql> USE information_schema;
mysql> SHOW TABLES;
+————————————+
| Tables_in_performance_schema |
+————————————+
| accounts |
| cond_instances |
| events_wts_current |
| events_wts_history |
| events_wts_history_long |
| external_locks |
| file_instances |
| file_summary_by_event_name |
| file_summary_by_instance |
| host_summary |
| host_summary_by_file_io |
| host_summary_by_file_io_type |
| host_summary_by_stages |
| host_summary_by_statement_latency |
| innodb_buffer_stats_by_schema |
| innodb_buffer_stats_by_table |
| innodb_lock_wts |
| io_by_thread_by_latency |
| io_global_by_file_by_bytes |
| io_global_by_file_by_latency |
| io_global_by_wt_by_bytes |
| io_global_by_wt_by_latency |
| latest_file_uploads |
| memory_summary_by_account_by_event_name|
| memory_summary_by_host_by_event_name|
| memory_summary_by_thread_by_event_name|
| open_table_definitions |
| open_tables |
| performance_schema_backup_locks |
| performance_schema_locker |
| performance_schema_mutex_instances |
| performance_schema_rwlock_instances|
| performance_schema_session_connect_attrs|
| performance_schema_socket_instances|
| performance_schema_stage_instances |
| performance_schema_statement_ysis|
| performance_schema_table_handles |
| performance_schema_table_instances |
| performance_schema_thread_instances|
| performance_schema_users |
| performance_timers |
| prepared_statements_instances |
| processlist |
| ps_check_lost_instrumentation |
| ps_connection_events |
| ps_events_stages_histogram |
| ps_events_stages_summary_by_account_by_event_name|
| ps_events_stages_summary_by_host_by_event_name|
| ps_meta_events |
| ps_mutex_instances |
| ps_rwlock_instances |
| ps_setup_actors |
| ps_setup_objects |
| ps_setup_objects_summary |
| ps_statements_ysis |
| ps_statements_digest |
| ps_statements_digest_history |
| ps_status |
| ps_thread_events |
| ps_tls_channels |
| repeatable_read |
| schema_auto_increment_columns |
| schema_index_statistics |
| schema_object_instances |
| schema_redundant_indexes |
| schema_table_lock_wts |
| schema_table_statistics |
| schema_table_statistics_with_buffer|
| schema_triggers |
| schema_unused_indexes |
| session_account_connect_attrs |
| session_connect_attrs |
| setup_actors |
| setup_consumers |
| setup_instruments |
| setup_objects |
| setup_timers |
| socket_instances |
| stage_class |
| statement_ysis |
| statements_with_errors |
| statements_with_full_table_scans |
| statements_with_runtimes_in_95th_percentile|
| statements_with_sorting |
| statements_with_temp_tables |
| status_by_account |
| status_by_host |
| status_by_thread |
| status_by_user |
| table_handles |
| table_io_wts_summary_by_index_usage|
| table_lock_wts |
| table_partitions |
| table_replication_metadata |
| table_statistics |
| table_statistics_with_buffer |
| thread_pool_groups |
| thread_pool_resize_request |
| thread_pool_slave_threads |
| thread_pool_threads |
| user_defined_functions |
| user_variables_by_thread |
| wsrep_local_bf_aborts |
| wsrep_local_index |
| wsrep_local_state |
| wsrep_slave_FNO |
| wsrep_slave_GAP |
| wsrep_slave_threshold |
+————————————+
121 rows in set (0.00 sec)
四、
在使用數(shù)據(jù)庫(kù)的過(guò)程中,「切換」操作非常頻繁。在切換數(shù)據(jù)庫(kù)、表、模式的時(shí)候,一定要謹(jǐn)慎處理,以免出現(xiàn)誤操作。同時(shí),建議在進(jìn)行「切換」操作之前確認(rèn)好自己當(dāng)前的狀態(tài),以免造成不必要的損失。
成都網(wǎng)站建設(shè)公司-創(chuàng)新互聯(lián),建站經(jīng)驗(yàn)豐富以策略為先導(dǎo)10多年以來(lái)專(zhuān)注數(shù)字化網(wǎng)站建設(shè),提供企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),響應(yīng)式網(wǎng)站制作,設(shè)計(jì)師量身打造品牌風(fēng)格,熱線:028-86922220MYSQL 數(shù)據(jù)庫(kù)用什么命令切換數(shù)據(jù)庫(kù),謝謝大家教我。
要用哪個(gè)庫(kù) 就寫(xiě)
use 庫(kù)名
就前芹悉可以切換過(guò)首差去了慧乎
access:是一種桌面數(shù)據(jù)庫(kù),適合數(shù)據(jù)量較少的應(yīng)用,存儲(chǔ)數(shù)據(jù)庫(kù)(.mdb)文件大小賀燃缺不超過(guò)2g字節(jié),數(shù)據(jù)庫(kù)中的禪辯對(duì)象個(gè)數(shù)不超段哪過(guò)32,768。
程序如何在一臺(tái)電腦上兩個(gè)數(shù)據(jù)庫(kù)之間切換
在連接的時(shí)候數(shù)據(jù)庫(kù)的時(shí)候選擇一下,根據(jù)不同選擇調(diào)用不同連接字符串就行了。
數(shù)據(jù)庫(kù)怎么切換的介紹就聊到這里吧,感謝你花時(shí)間閱讀本站內(nèi)容,更多關(guān)于數(shù)據(jù)庫(kù)怎么切換,「數(shù)據(jù)庫(kù)」如何「切換」操作?,MYSQL 數(shù)據(jù)庫(kù)用什么命令切換數(shù)據(jù)庫(kù),謝謝大家教我。,程序如何在一臺(tái)電腦上兩個(gè)數(shù)據(jù)庫(kù)之間切換的信息別忘了在本站進(jìn)行查找喔。
成都創(chuàng)新互聯(lián)科技有限公司,經(jīng)過(guò)多年的不懈努力,公司現(xiàn)已經(jīng)成為一家專(zhuān)業(yè)從事IT產(chǎn)品開(kāi)發(fā)和營(yíng)銷(xiāo)公司。廣泛應(yīng)用于計(jì)算機(jī)網(wǎng)絡(luò)、設(shè)計(jì)、SEO優(yōu)化、關(guān)鍵詞排名等多種行業(yè)!
網(wǎng)頁(yè)題目:「數(shù)據(jù)庫(kù)」如何「切換」操作?(數(shù)據(jù)庫(kù)怎么切換)
文章出自:http://www.dlmjj.cn/article/cocejdj.html


咨詢
建站咨詢
