mysql> use test2; Database changed mysql> CREATE TABLE books ( id int(3) not null -> auto_increment, name char(50) not null, -> unique(id), primary key(id)); Query OK, 0 rows affected (0.00 sec)
現在我們用下列命令驗證一切正確無誤。
mysql> show tables +---------------------+ | Tables in test2 | +---------------------+ | books | +---------------------+ 1 row in set (0.00 sec)
mysql> describe books; +-------+-------------+------+------+----------+------------------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+------+----------+------------------------+ | id | int(3) | | PRI | 0 | auto_increment |
| name | char(50) | | | | | +-------+-------------+------+------+----------+------------------------+ 2 rows in set (0.00 sec)
注意到describe命令基本上“描述”了表的布局。相當不錯吧!
好,該試一些確實有用的SQL命令,插入并從數據庫中選擇數據,現在把幾個記錄加到新表中。記住這些是簡單的書名記錄,但是一旦你獲得了SQL足夠的經驗,你可以為一些大的電子商務站點創(chuàng)建確實復雜的數據庫。讓我們創(chuàng)建2本假想的書的2條記錄。第一條記錄是我在將來某天寫的一本書的名字-“PHP 4 Newbies”,另一本是一個很有用的Linux書,“Red Hat Linux 6 Server”, 由Mohammed J. Kabir所著。
mysql> INSERT INTO books (name) values("PHP 4 Newbies"); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO books (name) values("Red Hat Linux 6 Server"); Query OK, 1 row affected (0.00 sec)
現在我們可以檢查新紀錄,發(fā)出一條“選擇所有”命令
mysql> SELECT * from books; +----+----------------------------------+ | id | name | +----+----------------------------------+ | 1 | PHP for Newbies | | 2 | Red Hat Linux 6 Server | +----+----------------------------------+ 2 rows in set (0.00 sec)
mysql> delete from books where id=1; Query OK, 1 row affected (0.00 sec) mysql> select * from books; +----+-----------------------------------+ | id | name | +----+-----------------------------------+ | 2 | Red Hat Linux 6 Server | +----+-----------------------------------+ 1 row in set (0.00 sec)
+-----------------------------------------------------------------------+ | Before you install the package you now should prepare the SSL | | certificate system by running the "make certificate" command. | | For different situations the following variants are provided: | | | | % make certificate TYPE=dummy (dummy self-signed Snake Oil cert) | | % make certificate TYPE=test (test cert signed by Snake Oil CA) | | % make certificate TYPE=custom (custom cert signed by own CA) | | % make certificate TYPE=existing (existing cert) | | CRT=/path/to/your.crt [KEY=/path/to/your.key] | | | | Use TYPE=dummy when you‘re a vendor package maintainer, | | the TYPE=test when you‘re an admin but want to do tests only, | | the TYPE=custom when you‘re an admin willing to run a real server | | and TYPE=existing when you‘re an admin who upgrades a server. | | (The default is TYPE=test) | | | | Additionally add ALGO=RSA (default) or ALGO=DSA to select | | the signature algorithm used for the generated certificate. | | | | Use "make certificate VIEW=1" to display the generated data. | | | | Thanks for using Apache & mod_ssl. Ralf S. Engelschall | | rse@engelschall.com | | www.engelschall.com | +-----------------------------------------------------------------------+
+----------------------------------------------------------------------------------+ | You now have successfully built and installed the | | Apache 1.3 HTTP server. To verify that Apache actually |
| works correctly you now should first check the | | (initially created or preserved) configuration files | | | | /usr/local/apache/conf/httpd.conf | | and then you should be able to immediately fire up | | Apache the first time by running: | | | | /usr/local/apache/bin/apachectl start | | Or when you want to run it with SSL enabled use: | | | | /usr/local/apache/bin/apachectl startssl | | Thanks for using Apache. The Apache Group | | http://www.apache.org / | +----------------------------------------------------------------------------------+
#--------------------------------------------------------# # VIRTUAL HOST SECTION NON-SSL #--------------------------------------------------------# # VirtualHost directive allows you to specify another virtual # domain on your server. Most Apache options can be specified # within this section.
# Where documents are kept in the virtual domain # this is an absolute path. So you may want to put # in a location where the owner can get to it. DocumentRoot /home/vhosts/domain1.com/www/
# Since we will use PHP to create basically # all our file we put a directive to the Index file. DirectoryIndex index.php
# Use CGI scripts in this domain. In the next case you # can see that it does not have CGI scripts. Please
# read up on the security issues relating to CGI-scripting. ScriptAlias /cgi-bin/ /var/www/cgi-bin/domain1.com/ AddHandler cgi-script .cgi AddHandler cgi-script .pl
# This is another domain. Note that you could host # multiple domains this way...
# General setup for the virtual host DocumentRoot /usr/local/apache/htdocs ServerAdmin webmaster@securedomain1.com ServerName www.securedomain1.com ErrorLoglogs/domain1.com-error_log TransferLog logs/domain1.com-transfer_log
# SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on
# Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A test
# certificate can be generated with `make certificate‘ under # built time. Keep in mind that if you‘ve both a RSA and a DSA # certificate you can configure both in parallel (to also allow # the use of DSA ciphers, etc.) # Note that I keep my certificate files located in a central # location. You could change this if you are an ISP, or ASP.
# Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you‘ve both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.)
# Per-Server Logging: # The home of a custom SSL log file. Use this when you want a # compact non-error SSL logfile on a virtual host basis. CustomLog /usr/local/apache/logs/ssl_request_log