PHP and MySQL Web Development - P45

PHP and MySQL Web Development - P45: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 192 Chapter 8 Creating Your Web Database Listing Continued create table orders orderid int unsigned not null auto_increment primary key customerid int unsigned not null amount float 6 2 date date not null create table books isbn char 13 not null primary key author char 30 title char 60 price float 4 2 create table order_items orderid int unsigned not null isbn char 13 not null quantity tinyint unsigned primary key orderid isbn create table book_reviews isbn char 13 not null primary key review text Each of the tables is created by a separate CREATE TABLE see that we ve created each of the tables in the schema with the columns that we designed in the last ll see that each of the columns has a data type listed after its name. Some of the columns have other specifiers too. What the Other Keywords Mean NOT NULL means that all the rows in the table must have a value in this attribute. If it isn t specified the field can be blank null . AUTO_INCREMENT is a special MySQL feature you can use on integer columns. It means if we leave that field blank when inserting rows into the table MySQL will automatically generate a unique identifier value. The value will be one greater than the maximum value in the column already. You can only have one of these in each table. Columns that specify AUTO_INCREMENT must be indexed. PRIMARY KEY after a column name specifies that this column is the primary key for the table. Entries in this column have to be unique. MySQL will automatically index this column. Notice that where we ve used it above with customerid in the customers table Creating Database Tables 193 we ve used it with AUTO_INCREMENT. The automatic index on the primary key takes care of the index required by AUTO_INCREMENT. Specifying PRIMARY KEY after a column name can only be used for single column primary PRIMARY KEY clause at the end of the order_items statement is an alternative form. We have used it here because the primary key for this

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
106    61    1    29-03-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.