MySQL tsim / tso lub rooj ib ntus li cas? Lub luag haujlwm ntawm MySQL cov ntxhuav ib ntus

Yuav ua li cas los tsim/rho tawm ib lub rooj ib ntus hauv MySQL ? Lub hom phiaj ntawm MySQL cov rooj ib ntus yog dab tsi?

MySQL ib ntus rooj

MySQL lub rooj ib ntus muaj txiaj ntsig zoo thaum peb xav tau khaws qee cov ntaub ntawv ib ntus.Cov ntxhuav ib ntus tsuas pom nyob rau hauv qhov kev sib txuas tam sim no.Thaum qhov kev sib txuas raug kaw, Mysql yuav rho tawm lub rooj thiab tso tag nrho qhov chaw.

Cov lus qhia ib ntus tau ntxiv rau hauv MySQL version 3.23. Yog tias koj qhov MySQL version qis dua 3.23, koj siv tsis tau MySQL cov lus qhia ib ntus. Txawm li cas los xij, cov kev pabcuam database MySQL qis no tsis tshua siv niaj hnub no.

Cov lus MySQL ib ntus tsuas yog pom ntawm qhov kev sib txuas tam sim no xwb. Yog tias koj siv PHP tsab ntawv los tsim MySQL lub rooj ib ntus, lub rooj ib ntus yuav raug puas tsuaj thaum twg PHP tsab ntawv raug tua.

Yog tias koj siv lwm qhov kev pabcuam MySQL tus neeg siv los txuas rau MySQL database server los tsim lub rooj ib ntus, lub rooj ib ntus tsuas yog raug rhuav tshem thaum cov neeg siv kev pabcuam raug kaw. Tau kawg, koj tuaj yeem rhuav tshem nws tus kheej.

piv txwv

Cov nram qab no qhia tau hais tias ib qho piv txwv yooj yim ntawm kev siv MySQL ib ntus cov lus, SQL code hauv qab no tuaj yeem siv rau mysql_query() kev ua haujlwm ntawm PHP tsab ntawv.

MySQL的> CREATE TEMPORARY TABLE SalesSummary (- > PRODUCT_NAME VARCHAR (50 )NOT NULL
     - > ,TOTAL_SALES DECIMAL (12 ,2 )NOT NULL DEFAULT 0.00 - > ,avg_unit_price DECIMAL (7 ,2 )NOT NULL DEFAULT 0.00 - > ,total_units_sold INT UNSIGNED NOT NULL DEFAULT 0 ); 查询OK ,0 行受影响(0.00 秒 
     
     
     

 )

的MySQL > INSERT INTO SalesSummary - > (PRODUCT_NAME ,TOTAL_SALES ,avg_unit_price ,total_units_sold )- > VALUES
     - > ('黄瓜' ,100.25 ,90 ,2 );
     
        

mysql > SELECT * FROM SalesSummary ; + -------------- + ------------- + ---------------- + --- --------------- + | product_name | total_sales | avg_unit_price | total_units_sold | + -------------- + ------------- + ---------------- + --- --------------- + | 黄瓜      | 100.25 | 90.00 | 2 | + -------------- + ------------- + ---------------- + --- --------------- + 1 行中集合(0.00 秒)



                                   

  

Thaum koj siv cov lus txib SHOW TABLES los tso saib cov npe ntawm cov rooj, koj yuav tsis pom lub rooj SalesSummary.

Yog tias koj tawm ntawm MySQL qhov kev sib tham tam sim no thiab tom qab ntawd siv cov lus txib SELECT los nyeem cov ntaub ntawv los ntawm lub rooj ib ntus uas tau tsim ua ntej, koj yuav pom tias lub rooj tsis muaj nyob hauv lub ntaub ntawv vim tias lub rooj ib ntus raug rhuav tshem thaum koj tawm mus.


Tso MySQL ib ntus rooj

Yog tias koj tsis txuas nrog lub database, cov rooj ib ntus yuav raug rhuav tshem thaum koj tsis txuas nrog lub database. Los yog, koj tuaj yeem rho tawm cov rooj ib ntus hauv MySQL tam sim no siv cov lus txib DROP TABLE .

Cov hauv qab no yog ib qho piv txwv ntawm manually tso lub rooj ib ntus:

mysql> CREATE TEMPORARY TABLE SalesSummary (
    -> product_name VARCHAR(50) NOT NULL
    -> , total_sales DECIMAL(12,2) NOT NULL DEFAULT 0.00
    -> , avg_unit_price DECIMAL(7,2) NOT NULL DEFAULT 0.00
    -> , total_units_sold INT UNSIGNED NOT NULL DEFAULT 0
);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO SalesSummary
    -> (product_name, total_sales, avg_unit_price, total_units_sold)
    -> VALUES
    -> ('cucumber', 100.25, 90, 2);

mysql> SELECT * FROM SalesSummary;
+--------------+-------------+----------------+------------------+
| product_name | total_sales | avg_unit_price | total_units_sold |
+--------------+-------------+----------------+------------------+
| cucumber     |      100.25 |          90.00 |                2 |
+--------------+-------------+----------------+------------------+
1 row in set (0.00 sec)
mysql>DROP TABLE SalesSummary ; 
mysql >   SELECT * FROM SalesSummary ; 
错误1146 :表'chenweiliang.SalesSummary' 不存在  

评论 评论

您的邮箱地址不会被公开。必填项已用*标注

Scroll rau saum