MySQL³£ÓÃÖ¸ÁºÏ
¼ÇÁËһЩÓà Windows µÄÃüÁîÐÐÀ´²Ù×÷ MySQL µÄÖ¸Áî¡£
ÕªÒª
Á¬½á MySQL
->mysql -u username -p
username ÊÇÄãµÄÕʺÅÃû³Æ¡£
Ô¶³ÌÁ¬½á
->mysql -h hostname -u username -p
hostname ÊÇ MySQL Ö÷»úµÄÃû³Æ¡£
ÏÔʾȫ²¿µÄÊý¾Ý¿â
SHOW DATABASES;
mysql ÊÇ MySQL ÓÃÀ´´¢´æÕʺźÍȨÏÞµÄÊý¾Ý¿â£¬²»ÄÜɾ³ý¡£
Ñ¡ÔñÊý¾Ý¿â
USE database_name;
ÏÔʾÊý¾Ý¿âÀïµÄ×ÊÁϱí
SHOW TABLES;
ÏÔʾ×ÊÁϱíµÄÐÅÏ¢
DESCRIBE table_name;
×¢Ïú MySQL ÏÔʾÆ÷
\q
SQL µÄÖ´ÐÐÖ¸Áî¿ÉÒÔ´ÓÎı¾ÎļþÄÚÊäÈë¡£
SOURCE file_name
Èç¹ûûÓеÇÈë MySQL µÄÏÔʾÆ÷£¬Óãº
->mysql -u username -p < file_name
Primary key - ÓÃÀ´Ê¶±ð×Ö¶ÎµÄ key¡£
Foreign key - ´ú±íÁ¬½áµÄ×ÊÁÏ±í¡£ÔÙÁíÒ»¸ö×ÊÁϱíÀïµÄ primary key¡£
ʹÓà MySQL
½¨Á¢Êý¾Ý¿â
CREATE DATABASE employee;
Õâ»á½¨Á¢Ò»¸ö½Ð employee µÄÊý¾Ý¿â¡£
½¨Á¢×ÊÁϱí
CREATE TABLE table_name (table definition) [type=table_type];
ÍêÕû¸ñʽ£º
³ÌÐò´úÂë:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name [(create_definition, ...)]
[table_options] [select_statement];
or
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name LIKE old_table_name;
create_definition:
col_name TYPE [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
[PRIMARY KEY] [reference_definition]
or PRIMARY KEY (index_col_name,...)
or KEY [index_name] (index_col_name,...)
or INDEX [index_name] (index_col_name,...)
or UNIQUE [INDEX] [index_name] (index_col_name,...)
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
[reference_definition]
or CHECK (expression)
TEMPORARY ¹Ø¼ü´ÊÊÇÓÃÀ´½¨Á¢ÔÝʱµÄ×ÊÁÏ±í£¬µ±ÄãµÄÁ¬½á½×¶Î½áÊøºó»á×Ô¶¯É¾³ý¡£
CREATE TEMPORARY TABLE table_name;
IF NOT EXISTS Ö»ÓÐÔÚ×ÊÁÏ±í²»´æÔÚʱ²Å»á½¨Á¢¡£
CREATE TABLE IF NOT EXISTS table_name;
LIKE old_table_name »áÒÀÕÕ old_table_name µÄ¹¹ÔìÀ´½¨Á¢ÐµÄ×ÊÁÏ±í¡£
×ֶζ¨Òå (column definition) ¿ÉÓõÄÑ¡Ï
NOT NULL »ò NULL À´¶¨Òå×ֶβ»ÄܰüÀ¨ NULL (NOT NULL) »ò¿ÉÒÔ°üÀ¨ NULL (NULL)¡£
ĬÈÏÖµÊ
Ïà¹ØÎĵµ£º
how to install apache, PHP and MySQL on Linux
This tutorial explains the installation of Apache web server, bundled
with PHP and MySQL server on a Linux machine. The tutorial is primarily for SuSE
9.2, 9.3, 10.0 & 10.1, but most of the steps ought to be valid for all
Linux-like operating ......
DELIMITER $$
DROP PROCEDURE IF EXISTS `heli`.`prodtest` $$
CREATE PROCEDURE `heli`.`prodtest` ()
BEGIN
/*¾Ö²¿±äÁ¿µÄ¶¨Òå declare*/
declare pid varchar(45) default '';
declare pq int default 0;
declare pk double default 0.0;
declare cur1 CURSOR FOR SELECT pro ......
1.PRIMARY KEY£¨Ö÷¼üË÷Òý£©
mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
2.UNIQUE(ΨһË÷Òý)
mysql>ALTER TABLE `table_name` ADD UNIQUE (
`column`
)
3.INDEX(ÆÕͨË÷Òý)
mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
4.FULLTEX ......