Danh mục

Linux all in one desk reference for dummies phần 4

Số trang: 88      Loại file: pdf      Dung lượng: 2.60 MB      Lượt xem: 12      Lượt tải: 0    
Hoai.2512

Phí tải xuống: 37,000 VND Tải xuống file đầy đủ (88 trang) 0
Xem trước 9 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu linux all in one desk reference for dummies phần 4, công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Linux all in one desk reference for dummies phần 4 207 DatabasesTo use MySQL, you have to first log in as root and start the database serverwith the following command:/etc/init.d/mysqld startThe database server mysqld is a daemon (a background process that runscontinuously) that accepts database queries from the MySQL monitor.Now you have to design a database, create that database in MySQL, and loadit with the data.Reviewing the steps to build the database Book II Chapter 4Use this basic sequence of steps to build a database: Introducing Linux 1. Design the database. Applications This involves defining the tables and attributes that will be used to store the information. 2. Create an empty database. Before you can add tables, database systems require you to build an empty database. 3. Create the tables in the database. In this step, you define the tables by using the CREATE TABLE statement of SQL. 4. Load the tables with any fixed data. For example, if you had a table of manufacturer names or publisher names (in the case of books), you’d want to load that table with information that’s already known. 5. Back up the initial database. This step is necessary to ensure that you can create the database from scratch, if necessary. 6. Load data into tables. You may either load data from an earlier dump of the database or inter- actively through forms. 7. Use the database by querying it. Make queries, update records, or insert new records using SQL commands.To illustrate how to create and load a database, I set up a simple book catalogdatabase as an example. TEAM LinG - Live, Informative, Non-cost and Genuine !208 Databases Designing the database For my book catalog example, I don’t follow all the steps of database build- ing. For the example, the database design step is going to be trivial because my book catalog database will include a single table. The attributes of the table are as follows: ✦ Book’s title with up to 50 characters ✦ Name of first author with up to 20 characters ✦ Name of second author (if any) with up to 20 characters ✦ Name of publisher with up to 30 characters ✦ Page count as a number ✦ Year published as a number (such as 2005) ✦ International Standard Book Number (ISBN), as a 10-character text (such as 0764579363) I store the ISBN without the dashes that are embedded in a typical ISBN. I also use the ISBN as the primary key of the table because ISBN is a world- wide identification system for books. That means each book entry must have a unique ISBN because all books have unique ISBNs. Creating an empty database To create the empty database in MySQL, use the mysqladmin program. For example, to create an empty database named books, I type the following command: mysqladmin create books You have to log in as root to run the mysqladmin program. As the name sug- gests, mysqladmin is the database administration program for MySQL. In addition to creating a database, you can use mysqladmin to remove a database, shutdown the database server, or check the MySQL version. For example, to see the version information, type the following command: mysqladmin version Using the MySQL monitor After you create the empty database, all of your interactions with the database are through the mysql program — the MySQL monitor that acts as a client to the database server. You need to run mysql with the name of a database as TEAM LinG - Live, Informative, Non-cost and Genuine ! 209 Databasesargument. The mysql program then prompts you for input. Here is an examplewhere I type the first line and the rest is the output from the mysql program:mysql booksReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 10 to server version: 3.23.49Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.mysql> ...

Tài liệu được xem nhiều: