SQL——MYSQL查詢語句大全,sqlmysql語句

來源:互聯網
上載者:User

SQL——MYSQL查詢語句大全,sqlmysql語句

1:使用SHOW語句找出在伺服器上當前存在什麼資料庫:

mysql> SHOW DATABASES;

2:2、建立一個資料庫MYSQLDATA

mysql> CREATE DATABASE MYSQLDATA;

3:選擇你所建立的資料庫

mysql> USE MYSQLDATA; (按斷行符號鍵出現Database changed時說明操作成功!)

4:查看現在的資料庫中存在什麼表

mysql> SHOW TABLES;

5:建立一個資料庫表

mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sexCHAR(1));

6:顯示表的結構:

mysql> DESCRIBE MYTABLE;

7:往表中加入記錄

mysql> insert into MYTABLE values (”hyq”,”M”);

8:用文本方式將資料裝入資料庫表中(例如D:/mysql.txt)

mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTOTABLE MYTABLE;

9:匯入.sql檔案命令(例如D:/mysql.sql)

mysql>use database;

mysql>source d:/mysql.sql;

10:刪除表

mysql>drop TABLE MYTABLE;

11:清空表

mysql>delete from MYTABLE;

12:更新表中資料

mysql>update MYTABLE set sex=”f” where name=’hyq’;

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.