溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何通過(guò)MySQ3.3參考手冊(cè)創(chuàng)建并使用數(shù)據(jù)庫(kù)

發(fā)布時(shí)間:2020-05-09 10:05:21 來(lái)源:億速云 閱讀:264 作者:三月 欄目:數(shù)據(jù)庫(kù)

本文主要給大家簡(jiǎn)單講講如何通過(guò)MySQ3.3參考手冊(cè)創(chuàng)建并使用數(shù)據(jù)庫(kù),相關(guān)專業(yè)術(shù)語(yǔ)大家可以上網(wǎng)查查或者找一些相關(guān)書籍補(bǔ)充一下,這里就不涉獵了,我們就直奔主題吧,希望如何通過(guò)MySQ3.3參考手冊(cè)創(chuàng)建并使用數(shù)據(jù)庫(kù)這篇文章可以給大家?guī)?lái)一些實(shí)際幫助。

3.3 Creating and Using a Database

3.3 創(chuàng)建 使用數(shù)據(jù)庫(kù)

  • 3.3.1 Creating and Selecting a Database

  • 3.3.2 Creating a Table

  • 3.3.3 Loading Data into a Table

  • 3.3.4 Retrieving Information from a Table


  • 3.3.1 創(chuàng)建和查看數(shù)據(jù)庫(kù)

  • 3.3.2 創(chuàng)建表

  • 3.3.3 將數(shù)據(jù)加載到表

  • 3.3.4 檢索表中的信息

如何通過(guò)MySQ3.3參考手冊(cè)創(chuàng)建并使用數(shù)據(jù)庫(kù)

Once you know how to enter SQL statements, you are ready to access a database.

上一節(jié)你知道了怎么輸入SQL 語(yǔ)句。你已經(jīng)準(zhǔn)備好訪問(wèn)數(shù)據(jù)庫(kù)了。

Suppose that you have several pets in your home (your menagerie) and you would like to keep track of various types of information about them. You can do so by creating tables to hold your data and loading them with the desired information. Then you can answer different sorts of questions about your animals by retrieving data from the tables. This section shows you how to perform the following operations:

假設(shè)你家有幾只寵物,你想追蹤他們的一些信息,你可以通過(guò)創(chuàng)建表來(lái)保存數(shù)據(jù),按照所需加載數(shù)據(jù)。你就可以從表中檢索數(shù)據(jù)來(lái)回答關(guān)于動(dòng)物的不同問(wèn)題。這一節(jié) 向你展示了 如何進(jìn)行以下操作。

  • Create a database

  • Create a table

  • Load data into the table

  • Retrieve data from the table in various ways

  • Use multiple tables

  • 創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)

  • 創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)

  • 向表中加載數(shù)據(jù)

  • 用不同的方式在表中檢索數(shù)據(jù)

  • 使用多個(gè)表

The menagerie database is simple (deliberately), but it is not difficult to think of real-world situations in which a similar type of database might be used. For example, a database like this could be used by a farmer to keep track of livestock, or by a veterinarian to keep track of patient records. A menagerie distribution containing some of the queries and sample data used in the following sections can be obtained from the MySQL Web site. It is available in both compressed tar file and Zip formats at http://dev.mysql.com/doc/.

menagerie 數(shù)據(jù)庫(kù)是簡(jiǎn)單的(故意的),但是不難想象真實(shí)情況下相似情況的數(shù)據(jù)庫(kù)。例如一個(gè)類似的數(shù)據(jù)庫(kù)可以被農(nóng)民用來(lái)記錄用來(lái)跟蹤牲畜,或由獸醫(yī)追蹤病寵的記錄。你可以從MySQL網(wǎng)站獲取menagerie數(shù)據(jù)庫(kù),它包含一些語(yǔ)句和簡(jiǎn)單的數(shù)據(jù)。在http://dev.mysql.com/doc/網(wǎng)站上提供 tar(linux) 和 Zip(windows)兩種打包的版本。

Use the SHOW statement to find out what databases currently exist on the server:

使用SHOW語(yǔ)句來(lái)查×××器上當(dāng)前存在的數(shù)據(jù)庫(kù):

mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql    |
| test     |
| tmp      |
+----------+

The mysql database describes user access privileges. The test database often is available as a workspace for users to try things out.

mysql 數(shù)據(jù)庫(kù) 描述了用戶的訪問(wèn)權(quán)限。test 數(shù)據(jù)庫(kù) 通常是給用戶提供測(cè)試空間。

The list of databases displayed by the statement may be different on your machine; SHOW DATABASES does not show databases that you have no privileges for if you do not have the SHOW DATABASES privilege. See Section 13.7.5.15, “SHOW DATABASES Syntax”.

語(yǔ)句顯示的數(shù)據(jù)庫(kù)列表可能在您的機(jī)器上不同; SHOW DATABASES不顯示那些 你沒(méi)有SHOW DATABASES 權(quán)限的數(shù)據(jù)庫(kù)。請(qǐng)參見(jiàn)第13.7.5.15節(jié)“SHOW DATABASES語(yǔ)法”。

If the test database exists, try to access it:

如果test數(shù)據(jù)庫(kù)存在,請(qǐng)嘗試訪問(wèn)它:

mysql> USE test
Database changed

USE, like QUIT, does not require a semicolon. (You can terminate such statements with a semicolon if you like; it does no harm.) The USE statement is special in another way, too: it must be given on a single line.

USE, 類似 QUIT,不需要分好(如果你喜歡,你可以使用分號(hào)終止這樣的語(yǔ)句;這樣做是OK的)另一方面 USE 是特殊的:use語(yǔ)句只能寫在一行之中。

You can use the test database (if you have access to it) for the examples that follow, but anything you create in that database can be removed by anyone else with access to it. For this reason, you should probably ask your MySQL administrator for permission to use a database of your own. Suppose that you want to call yours menagerie. The administrator needs to execute a statement like this:

您可以使用test數(shù)據(jù)庫(kù)(如果您有權(quán)訪問(wèn)該數(shù)據(jù)庫(kù))以獲得以下示例,但是任何可以訪問(wèn)該數(shù)據(jù)庫(kù)的人都可以刪除該數(shù)據(jù)庫(kù)中創(chuàng)建的任何內(nèi)容。因此,您可以要求您的MySQL管理員僅僅允許你訪問(wèn)該數(shù)據(jù)庫(kù)。假設(shè)你想訪問(wèn)你的 menagerie數(shù)據(jù)庫(kù)。管理員需要執(zhí)行如下語(yǔ)句:

mysql> GRANT ALL ON menagerie.* TO 'your_mysql_name'@'your_client_host';

where your_mysql_name is the MySQL user name assigned to you and your_client_host is the host from which you connect to the server.

your_mysql_name 是分配給您的MySQL用戶名,your_client_host是你的主機(jī)。

如何通過(guò)MySQ3.3參考手冊(cè)創(chuàng)建并使用數(shù)據(jù)庫(kù)就先給大家講到這里,對(duì)于其它相關(guān)問(wèn)題大家想要了解的可以持續(xù)關(guān)注我們的行業(yè)資訊。我們的板塊內(nèi)容每天都會(huì)捕捉一些行業(yè)新聞及專業(yè)知識(shí)分享給大家的。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI