จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Firebase Realtime Database
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
จัดเก็บและซิงค์ข้อมูลกับฐานข้อมูลระบบคลาวด์ NoSQL ข้อมูล
จะซิงค์ระหว่างไคลเอ็นต์ทั้งหมดแบบเรียลไทม์ และยังคงใช้งานได้เมื่อ
ออฟไลน์ได้
Firebase Realtime Database เป็นฐานข้อมูลที่โฮสต์บนระบบคลาวด์ ระบบจัดเก็บข้อมูลเป็น JSON
และซิงค์แบบเรียลไทม์กับไคลเอ็นต์ที่เชื่อมต่อทั้งหมด เมื่อคุณสร้าง
แอปข้ามแพลตฟอร์มด้วยแพลตฟอร์ม Apple, Android และ JavaScript SDK ของเรา
ไคลเอ็นต์จะแชร์อินสแตนซ์ Realtime Database หนึ่งอินสแตนซ์และรับการอัปเดตโดยอัตโนมัติด้วย
ข้อมูลใหม่ล่าสุด
หรือลองใช้ Cloud Firestore สำหรับโหมดสมัยใหม่
แอปพลิเคชันที่ต้องใช้โมเดลข้อมูลที่สมบูรณ์ยิ่งขึ้น ความสามารถในการค้นหา ความสามารถในการปรับขนาด
หากพร้อมที่จะเริ่มแล้ว เลือกแพลตฟอร์ม:
iOS
แอนดรอยด์
เว็บ
Flutter
Unity
C++
ผู้ดูแลระบบ
API ของ REST
ความสามารถที่สำคัญ
เรียลไทม์ |
Firebase Realtime Database ใช้ข้อมูลแทนคำขอ HTTP ทั่วไป
การซิงค์ - ทุกครั้งที่ข้อมูลเปลี่ยนแปลง อุปกรณ์ที่เชื่อมต่อใดๆ จะได้รับ
ที่อัปเดตภายในมิลลิวินาที มอบการทำงานร่วมกันและ
ประสบการณ์ที่สมจริงโดยไม่ต้องคำนึงถึงโค้ดเครือข่าย
|
ออฟไลน์ |
แอป Firebase ยังคงตอบสนองได้แม้ในขณะออฟไลน์เนื่องจาก
SDK ของ Firebase Realtime Database จะเก็บข้อมูลของคุณไว้ในดิสก์ เมื่อเชื่อมต่อแล้ว
ได้รับการสร้างใหม่ อุปกรณ์ไคลเอ็นต์ได้รับการเปลี่ยนแปลงที่พลาดไป
กำลังซิงค์ข้อมูลกับสถานะเซิร์ฟเวอร์ปัจจุบัน
|
เข้าถึงได้จากอุปกรณ์ไคลเอ็นต์ |
เข้าถึง Firebase Realtime Database ได้โดยตรงจากอุปกรณ์เคลื่อนที่
หรือเว็บเบราว์เซอร์ โดยไม่ต้องใช้แอปพลิเคชันเซิร์ฟเวอร์เลย ความปลอดภัยและ
การตรวจสอบข้อมูลพร้อมให้บริการผ่าน Firebase Realtime Database
กฎความปลอดภัย กฎตามนิพจน์ที่จะทำงานเมื่อข้อมูล
อ่านหรือเขียนแล้ว
|
ปรับขนาดให้เหมาะกับฐานข้อมูลที่หลากหลาย |
เมื่อใช้ Firebase Realtime Database ในแพ็กเกจราคา Blaze คุณจะสนับสนุน
ต้องการข้อมูลของแอปในวงกว้างด้วยการแบ่งข้อมูลออกเป็น
อินสแตนซ์ฐานข้อมูลในโปรเจ็กต์ Firebase เดียวกัน ปรับปรุงการตรวจสอบสิทธิ์
กับ Firebase Authentication ในโปรเจ็กต์และตรวจสอบสิทธิ์ผู้ใช้
อินสแตนซ์ฐานข้อมูลของคุณ ควบคุมการเข้าถึงข้อมูลในแต่ละฐานข้อมูลด้วย
Firebase Realtime Database Security Rules ที่กำหนดเองสำหรับอินสแตนซ์ฐานข้อมูลแต่ละรายการ
|
วิธีการทำงาน
Firebase Realtime Database ช่วยให้คุณสามารถสร้างแอปพลิเคชันสำหรับการทำงานร่วมกันได้อย่างมีประสิทธิภาพ
โดยการให้สิทธิ์เข้าถึงฐานข้อมูลอย่างปลอดภัยโดยตรงจากโค้ดฝั่งไคลเอ็นต์ ข้อมูล
จะคงอยู่ในเครื่อง และแม้ว่าออฟไลน์ เหตุการณ์แบบเรียลไทม์ก็จะยังคงเริ่มทำงานต่อไป
ทำให้ผู้ใช้ปลายทางได้รับประสบการณ์
ที่ตอบสนองตามอุปกรณ์ เมื่ออุปกรณ์กลับมาเชื่อมต่ออีกครั้ง
Realtime Database จะซิงค์ข้อมูลการเปลี่ยนแปลงข้อมูลในเครื่องกับการอัปเดตจากระยะไกล
ที่เกิดขึ้นขณะที่ไคลเอ็นต์ออฟไลน์อยู่ แล้วผสานความขัดแย้งโดยอัตโนมัติ
Realtime Database จะใช้ภาษาสำหรับกฎตามนิพจน์และมีความยืดหยุ่น
กฎความปลอดภัยFirebase Realtime Database เพื่อกำหนดว่าข้อมูลควรเป็นอย่างไร
ที่มีโครงสร้างและเวลาที่สามารถอ่านหรือเขียนข้อมูลได้ เมื่อผสานรวมกับ
Firebase Authentication นักพัฒนาแอปจะกําหนดได้ว่าใครมีสิทธิ์เข้าถึงข้อมูลใดบ้างและต้องทำอย่างไร
นักเรียนเข้าถึงได้
Realtime Database เป็นฐานข้อมูล NoSQL จึงมีการเพิ่มประสิทธิภาพที่แตกต่างกัน
และความสามารถต่างๆ เมื่อเทียบกับฐานข้อมูลเชิงสัมพันธ์ Realtime Database API คือ
ที่ออกแบบมาเพื่ออนุญาตการดำเนินการ
ที่สามารถดำเนินการได้อย่างรวดเร็วเท่านั้น ซึ่งช่วยให้คุณ
สร้างประสบการณ์แบบเรียลไทม์ที่ยอดเยี่ยม
สามารถให้บริการผู้ใช้หลายล้านคน
ส่งผลต่อการตอบสนอง ด้วยเหตุนี้ คุณจึงควรคำนึงถึง
วิธีที่ผู้ใช้ต้องการเข้าถึงข้อมูลของคุณแล้ว
จัดโครงสร้างให้สอดคล้อง
เส้นทางการใช้งาน
|
ผสานรวม SDK Firebase Realtime Database รายการ |
รวมลูกค้าได้อย่างรวดเร็วโดยใช้ Gradle, CocoaPods หรือสคริปต์ ซึ่งรวมถึง |
|
สร้างข้อมูลอ้างอิง Realtime Database รายการ |
อ้างอิงข้อมูล JSON เช่น "users/user:1234/phone_number" เพื่อตั้งค่า
หรือสมัครรับการเปลี่ยนแปลงข้อมูล
|
|
ตั้งค่าข้อมูลและรอรับการเปลี่ยนแปลง |
ใช้การอ้างอิงเหล่านี้เพื่อเขียนข้อมูลหรือสมัครรับการเปลี่ยนแปลง |
|
เปิดใช้ความต่อเนื่องแบบออฟไลน์ |
อนุญาตให้เขียนข้อมูลลงในดิสก์ภายในอุปกรณ์เพื่อให้สามารถใช้งานได้
ขณะที่ออฟไลน์
|
|
รักษาความปลอดภัยให้ข้อมูลของคุณ |
ใช้กฎความปลอดภัย Firebase Realtime Database เพื่อรักษาความปลอดภัยของข้อมูล |
จัดเก็บข้อมูลประเภทอื่นๆ
- Cloud Firestore เป็นฐานข้อมูลที่ยืดหยุ่นและรองรับการปรับขนาดสำหรับ
การพัฒนาอุปกรณ์เคลื่อนที่ เว็บ และเซิร์ฟเวอร์จาก Firebase และ Google Cloud
ดูข้อมูลเพิ่มเติมเกี่ยวกับความแตกต่างระหว่างตัวเลือกฐานข้อมูลได้ที่
เลือกฐานข้อมูล: Cloud Firestore หรือ Realtime Database
- Firebase Remote Config Store ที่ระบุโดยนักพัฒนาแอป
คู่คีย์-ค่าเพื่อเปลี่ยนลักษณะการทำงานและรูปลักษณ์ของแอป
การกำหนดให้ผู้ใช้ดาวน์โหลดอัปเดต
- Firebase Hosting โฮสต์ HTML, CSS และ
JavaScript สำหรับเว็บไซต์ รวมถึงชิ้นงานอื่นๆ ที่นักพัฒนาซอฟต์แวร์ให้ไว้ เช่น
กราฟิก แบบอักษร และไอคอน
- Cloud Storage จะจัดเก็บไฟล์ เช่น รูปภาพ
วิดีโอ เสียง รวมถึงเนื้อหาอื่นๆ ที่ผู้ใช้สร้างขึ้น
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# Firebase Realtime Database\n==========================\n\nplat_ios plat_android plat_web plat_flutter plat_cpp plat_unity \nStore and sync data with our NoSQL cloud database. Data\nis synced across all clients in realtime, and remains available when your\napp goes offline. \n\n### Realtime Database\n\n### Cloud Firestore\n\nPreferred \nThe Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON\nand synchronized in realtime to every connected client. When you build\ncross-platform apps with our Apple platforms, Android, and JavaScript SDKs, all of your\nclients share one Realtime Database instance and automatically receive updates with\nthe newest data.\n\nAlternatively, consider trying [Cloud Firestore](/docs/firestore) for modern\napplications requiring richer data models, queryability, scalability and higher\navailability.\n\n\u003cbr /\u003e\n\nReady to get started? Choose your platform:\n\n[iOS+](/docs/database/ios/start)\n[Android](/docs/database/android/start)\n[Web](/docs/database/web/start)\n[Flutter](/docs/database/flutter/start)\n[Unity](/docs/database/unity/start)\n[C++](/docs/database/cpp/start)\n[Admin](/docs/database/admin/start)\n[REST API](/docs/database/rest/start) \n\nKey capabilities\n----------------\n\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Realtime | Instead of typical HTTP requests, the Firebase Realtime Database uses data synchronization---every time data changes, any connected device receives that update within milliseconds. Provide collaborative and immersive experiences without thinking about networking code. |\n| Offline | Firebase apps remain responsive even when offline because the Firebase Realtime Database SDK persists your data to disk. Once connectivity is reestablished, the client device receives any changes it missed, synchronizing it with the current server state. |\n| Accessible from Client Devices | The Firebase Realtime Database can be accessed directly from a mobile device or web browser; there's no need for an application server. Security and data validation are available through the Firebase Realtime Database Security Rules, expression-based rules that are executed when data is read or written. |\n| Scale across multiple databases | With Firebase Realtime Database on the Blaze pricing plan, you can support your app's data needs at scale by splitting your data across multiple database instances in the same Firebase project. Streamline authentication with Firebase Authentication on your project and authenticate users across your database instances. Control access to the data in each database with custom Firebase Realtime Database Security Rules for each database instance. |\n\nHow does it work?\n-----------------\n\nThe Firebase Realtime Database lets you build rich, collaborative applications\nby allowing secure access to the database directly from client-side code. Data\nis persisted locally, and even while offline, realtime events continue to fire,\ngiving the end user a responsive experience. When the device regains connection,\nthe Realtime Database synchronizes the local data changes with the remote updates\nthat occurred while the client was offline, merging any conflicts automatically.\n\nThe Realtime Database provides a flexible, expression-based rules language,\ncalled Firebase Realtime Database Security Rules, to define how your data should be\nstructured and when data can be read from or written to. When integrated with\nFirebase Authentication, developers can define who has access to what data, and how\nthey can access it.\n\nThe Realtime Database is a NoSQL database and as such has different optimizations\nand capabilities compared to a relational database. The Realtime Database API is\ndesigned to only allow operations that can be executed quickly. This lets you\nbuild a great realtime experience that can serve millions of users without\ncompromising on responsiveness. Because of this, it is important to think about\nhow users need to access your data and then\n[structure it accordingly](/docs/database/web/structure-data).\n\nImplementation path\n-------------------\n\n|---|-----------------------------------------------|------------------------------------------------------------------------------------------------------------|\n| | Integrate the Firebase Realtime Database SDKs | Quickly include clients using Gradle, CocoaPods, or a script include. |\n| | Create Realtime Database References | Reference your JSON data, such as \"users/user:1234/phone_number\" to set data or subscribe to data changes. |\n| | Set Data and Listen for Changes | Use these references to write data or subscribe to changes. |\n| | Enable Offline Persistence | Allow data to be written to the device's local disk so it can be available while offline. |\n| | Secure your data | Use Firebase Realtime Database Security Rules to secure your data. |\n\nStore other types of data\n-------------------------\n\n- [Cloud Firestore](/docs/firestore) is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud. To learn more about the differences between database options, see [Choose a database: Cloud Firestore or Realtime Database](/docs/firestore/rtdb-vs-firestore).\n- [Firebase Remote Config](/docs/remote-config) stores developer specified key-value pairs to change the behavior and appearance of your app without requiring users to download an update.\n- [Firebase Hosting](/docs/hosting) hosts the HTML, CSS, and JavaScript for your website as well as other developer-provided assets like graphics, fonts, and icons.\n- [Cloud Storage](/docs/storage) stores files such as images, videos, and audio as well as other user-generated content.\n\nNext steps:\n-----------\n\n- Set data and listen for changes using the [Apple platforms](/docs/database/ios/start), [Android](/docs/database/android/start), [Web](/docs/database/web/start), [Admin](/docs/database/admin/start) SDKs, or the [REST API](/docs/database/rest/start).\n- Add Firebase Realtime Database to your [Apple](/docs/database/ios/start), [Android](/docs/database/android/start), or [Web](/docs/database/web/start) app.\n- Learn about how to secure your files using [Firebase Realtime Database Security Rules](/docs/database/security)."]]