sql azure 语法_什么是Azure SQL Cosmos DB?

sql azure 语法

介绍 (Introduction)

In the Azure Portal, you will find the option to install Azure SQL Cosmos DB. So, what is Cosmos DB, exactly?

在Azure门户中,您将找到安装Azure SQL Cosmos DB的选项。 那么,什么是Cosmos DB?

This article will clarify what Azure SQL Cosmos DB is, how much it costs, how to integrate it with SQL Server, how to scale the database and other related information.

本文将阐明什么是Azure SQL Cosmos DB,其成本,如何将其与SQL Server集成,如何扩展数据库以及其他相关信息。

什么是Azure SQL Cosmos DB? (What is Azure SQL Cosmos DB?)

It sounds like a Database to store documents, but it is a NoSQL Database used to store non-structured data in Azure. It was created by Microsoft as a high performance non-normalized database. It is flexible, with high availability and automatic scaling.

听起来像是一个用于存储文档的数据库,但是它是一个NoSQL数据库,用于在Azure中存储非结构化数据。 它是由Microsoft创建的高性能非标准化数据库。 它非常灵活,具有高可用性和自动缩放功能。

Cosmos DB, is not used to store documents like MS Words or PDF documents. It is used to store JSON documents.

Cosmos DB不用于存储MS Word或PDF文档之类的文档。 它用于存储JSON文档。

什么是JSON? (What is JSON?)

JSON (Java Script Object Notation) is a standard object notation used to transmit data objects. It is very popular in Web Services where it is replacing XML. It started on Java Script, but now it is a standard supported in several programming languages.

JSON(Java脚本对象表示法)是用于传输数据对象的标准对象表示法。 它在替换XML的Web服务中非常流行。 它始于Java Script,但现在已成为多种编程语言支持的标准。

学习JSON很难吗? (Is it hard to learn JSON?)

No, if you are a programmer, it will be a straightforward to learn JSON, because the object notation is very easy. If you are a DBA, it might be a little bit more difficult. In SQL Server 2016, JSON support is included, so, it looks like it is something that a DBA needs to eventually learn. In SQL Server if you are familiar with XML, using JSON will be very easy because the sentences are similar.

不,如果您是一名程序员,那么学习JSON将非常简单,因为对象表示法非常简单。 如果您是DBA,可能会有些困难。 在SQL Server 2016中,包括了JSON支持,因此,看起来DBA最终需要学习它。 在SQL Server中,如果您熟悉XML,则使用JSON将非常容易,因为句子很相似。

JSON语法示例 (JSON syntax example)

Here is an example for learning JSON:

这是学习JSON的示例:

 
{"customers":[
{"firstName":"John", "lastName":"Smith", "email":"jsmith@hotmail.com" },
{"firstName":"Peter", "lastName":"Jackson", "email":"pjackson@hotmail.com" },
{"firstName":"Maria", "lastName":"Simpson", "email":"msimpson@hotmail.com" }
]}
 

It is not hard.. The customer in the sample is the object and the firstName, lastName and email are the names with their values. The syntax is easy to read and very flexible. The data is separated by commas. Curly braces contain the objects and the square brackets contain arrays.

这并不难。样本中的客户是对象,而firstName,lastName和email是带有其值的名称。 语法易于阅读且非常灵活。 数据用逗号分隔。 花括号包含对象,方括号包含数组。

If you have worked with C# and Java, you know that it not so easy to parse elements from XML (at least not the first time). In JSON it is easier. That is why XML is dying and JSON is replacing it (however, in SQL Server using JSON is not easier than XML).

如果您使用过C#和Java,那么您就会知道,解析XML中的元素并不是那么容易(至少不是第一次)。 在JSON中更容易。 这就是XML快要枯竭而JSON取代它的原因(但是,在SQL Server中使用JSON并不比XML容易)。

JSON is very common also in Big Data (Azure HDInsight for example).

JSON在大数据中也很常见(例如,Azure HDInsight)。

Q: OK, everything is stored in JSON documents, but how can I query the Azure SQL Cosmos DB data?

问:好的,所有内容都存储在JSON文档中,但是如何查询Azure SQL Cosmos DB数据?

A: You can use traditional SQL. It may sound weird because Cosmos DB is for non-structured data, but Microsoft tried to make our life easier. That is why you can easily learn how to query Cosmos DB.

答:您可以使用传统SQL。 这听起来很奇怪,因为Cosmos DB用于非结构化数据,但是Microsoft试图使我们的生活更轻松。 这就是为什么您可以轻松学习如何查询Cosmos DB的原因。

Q: Cosmos DB is not related to Azure SQL Server. In which scenarios should I use Azure SQL Server and in which scenarios Cosmos DB?

问:Cosmos DB与Azure SQL Server不相关。 在哪些情况下应使用Azure SQL Server,在哪些情况下应使用Cosmos DB?

A: Cosmos DB is used specially in gaming, Social media and IoT (Internet Of Things) applications. If you have an application and it need to scale around the world and you have millions of users, Cosmos DB in Azure is a simple and inexpensive solution. Azure SQL for several millions of users is harder to scale. In general, a traditional Relational Database cannot scale as easy as simple JSON documents. The other problem is the data. Some applications require images and videos. It is really hard to store and handle these types of data in a relational database like Azure SQL.

答:Cosmos DB特别用于游戏,社交媒体和IoT(物联网)应用程序。 如果您拥有一个应用程序,并且需要在全球范围内扩展,并且您拥有数百万的用户,则Azure中的Cosmos DB是一种简单且廉价的解决方案。 数百万用户的Azure SQL很难扩展。 通常,传统的关系数据库无法像简单的JSON文档那样轻松地扩展。 另一个问题是数据。 某些应用程序需要图像和视频。 在像Azure SQL这样的关系数据库中存储和处理这些类型的数据确实非常困难。

A SQL Azure database is a great solution when you do not need to scale and deal with millions of users at the same time and the relational model is also a good idea.

当您不需要同时扩展和处理数百万个用户并且关系模型也是一个好主意时,SQL Azure数据库是一个很好的解决方案。

哪些客户正在使用Azure SQL Cosmos DB? (What customers are using Azure SQL Cosmos DB?)

One important customer is MSN.com, a web portal with half a billion monthly users and 20 TB of document storage.

一个重要的客户是MSN.com,这是一个拥有十亿月度用户和20 TB文档存储空间的门户网站。

Next games, a gaming company required a low latency solution to store for millions of users. They required to store millions of profiles from Facebook, Google, GameCenter and store the scores, chat messages, challenges, etc.

在接下来的游戏中 ,游戏公司需要一种低延迟解决方案来存储数百万用户。 他们需要存储来自Facebook,Google,GameCenter的数百万个个人资料,并存储分数,聊天消息,挑战等。

Halo 5, a popular XBOX game with more than 65 millions of users.

Halo 5,一款受欢迎的XBOX游戏,拥有超过6500万用户。

As you can see, usually we talk about several millions of users, low latency and a scalable solution.

如您所见,通常我们谈论的是数百万用户,低延迟和可扩展的解决方案。

听起来不错。 多少钱? (Sounds fine. What is the price?)

There are two ways:

有两种方法:

Pre-defined and User defined billing.

预定义和用户定义的帐单。

Pre-defined performance billing that depended on the data storage and the request units.

预定义的性能计费取决于数据存储和请求单位。

A S1 collection with 10 GB of storage and 250 request units per second costs $25 per month and a S3 with the same storage and 2500 request units per second costs $100 per month.

具有10 GB存储空间和每秒250个请求单位的S1集合每月费用为25美元,具有相同存储空间和每秒2500个请求单位的S3每月花费100美元。

The User-defined performance billing offers a storage of $0.25 per GB per month and each 100 request units reserved per $6 per month.

用户定义的性能计费提供每月每GB 0.25 USD的存储空间,以及每100 USD每月预留100个请求单位。

请求单位是什么? (What are the request units?)

A Request Unit is the throughput to get 1 KB document.

请求单位是获取1 KB文档的吞吐量。

什么是收藏集? (What is a collection?)

It is a container of JSON documents. You can have several collections in the same database. The size of a collection is unlimited because it can be compound of multiple disks from multiple servers.

它是JSON文档的容器。 您可以在同一数据库中有多个集合。 集合的大小不受限制,因为它可以由来自多个服务器的多个磁盘组成。

如何从SQL Server迁移到Azure SQL Cosmos DB? (How can I migrate from SQL Server to Azure SQL Cosmos DB?)

You can use the Cosmos DB Data Migration Tool. It is an open source to import data from SQL Server and other sources like CSV files, MongoDB, Azure Table Storage and other sources.

您可以使用Cosmos DB数据迁移工具。 它是从SQL Server和其他来源(例如CSV文件,MongoDB,Azure Table Storage和其他来源)导入数据的开源。

Cosmos DB如何扩展? (How does the Cosmos DB scale?)

The collections can be stored in multiple partitions. The information is stored in multiple solid state disks. If you need more disks, the database grows. The scaling is unlimited. For the partition it is used a partition key. The number specifies the partition used.

集合可以存储在多个分区中。 该信息存储在多个固态磁盘中。 如果需要更多磁盘,则数据库会增长。 缩放是无限的。 对于分区,使用分区键。 该数字指定使用的分区。

如何检索Azure SQL Cosmos数据库信息? (How can I retrieve the Azure SQL Cosmos DB information?)

Cosmos DB has a REST API that allows it to be called by any language capable of handling HTTP and HTTPS requests. There are libraries for Java, .NET, Python.

Cosmos DB具有REST API,可通过任何能够处理HTTP和HTTPS请求的语言进行调用。 有用于Java,.NET,Python的库。

结论 (Conclusion)

Azure SQL Cosmos DB is a new NoSQL database offered in Azure. It is a simple and inexpensive solution in the cloud used specially in Online Games, IoT applications and Social Media and other application with millions of users. It is possible to migrate data from SQL Server to Cosmos DB. The information is stored in JSON documents.

Azure SQL Cosmos DB是Azure中提供的新的NoSQL数据库。 它是一种简单,廉价的云解决方案,专门用于在线游戏,IoT应用程序和社交媒体以及数百万用户的其他应用程序。 可以将数据从SQL Server迁移到Cosmos DB。 该信息存储在JSON文档中。

The use of the NoSQL databases is growing because of the volume of data required to store them.

由于存储NoSQL数据库需要大量数据,因此NoSQL数据库的使用正在增长。

翻译自: https://www.sqlshack.com/what-is-azure-cosmos-db/

sql azure 语法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值