|
1.
Basic MySQL commands.
1. To create a new
table;
CREATE TABLE table_name(column_specs);
CREATE TABLE EMPLOYEE
(
emp_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY
KEY,
emp_fname VARCHAR(15) NULL,
emp_mname VARCHAR(15) NULL,
emp_lname VARCHAR(15) NULL,
street VARCHAR(35) NULL,
city VARCHAR(20) NULL,
state VARCHAR(2) NULL,
zip VARCHAR(10) NULL,
phone_h VARCHAR(18) NULL,
phone_b VARCHAR(18) NULL,
phone_c VARCHAR(18) NULL,
fax VARCHAR(18) NULL,
birthdate DATE NULL,
hire_date DATE NULL,
terminate DATE NULL,
ssno VARCHAR(11) NULL,
drvno VARCHAR(12) NULL,
memo_note VARCHAR(150) NULL
);
2. DESCRIBE(describe,
desc) is useful when you forget the name of a column
in a table;
mysql>DESCRIBE
EMPLOYEE;
3. What if you forget
the names of your tables?
mysql>SHOW TABLES;
4. Retrieving Information
mysql>SELECT
* FROM EMPLOYEE;
5. You can specify
the initial sequence number explicitly when you create
the table as follows.
CREATE TABLE EMPLOYEE
(
emp_id INT(5) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY
KEY) AUTO_INCREMENT = 10000;
2.
PHP4 MySQL; Basic Connectiviry.
PHP provides the
mysql_connect() function to create a connection to a
MySQL database server with three string arguments.
$connection = mysql_connect("www.ekoo.com","username","password");
Remember the hostname,
username, password to connect to the database server.
|