mysql基礎語句

2021-07-08 18:55:18 字數 3063 閱讀 5245

一.如何進入mysql 在window下面的cmd下

mysql --help //將顯示所有的幫助資訊

mysql --version //將顯示版本資訊

mysql --host=/-h 主機名  //聯結到某個主機  localhost預設本地

mysql --user=/-u 使用者名稱

mysql --password/-p 密碼 按下回車再輸入比較好

mysql --compress 壓縮傳輸

二.mysql的一些命令

?         (\?) synonym for `help'.

clear     (\c) clear the current input statement.

connect   (\r) reconnect to the server. optional arguments are db and host.

delimiter (\d) set statement delimiter.  //語句結束符

ego       (\g) send command to mysql server, display result vertically.

exit      (\q) exit mysql. same as quit.

go        (\g) send command to mysql server.

help      (\h) display this help.

notee     (\t) don't write into outfile.

print     (\p) print current command.

prompt    (\r) change your mysql prompt. //提示符

quit      (\q) quit mysql.

rehash    (\#) rebuild completion hash.

source    (\.) execute an sql script file. takes a file name as an argument.

status    (\s) get status information from the server.

use       (\u) use another database. takes database name as argument.

charset   (\c) switch to another charset. might be needed for processing binlog with multi-byte charsets.

warnings  (\w) show warnings after every statement.

nowarning (\w)  do not show warnings after every statement.

三.進入資料後進行的操作    

一.庫的操作

1.庫的建立

create database [if not exists] database_name;

2.庫的修改

alter database database_name character set latin(字符集名字) collate utf8_polish_ci(校對規則ci代表大小寫不敏感);

3.庫的刪除

drop database [if exists] database_name;

4.庫的使用

use database_name //就ok了

5.顯示庫中的表

show tables;

6.select version(),database();顯示版本資訊,資料庫名字

二.表的操作 

1.表的建立

create table class130 (

id int not null auto_increment,

name varchar not null,

address varchar(20),

primary key(id)

) engine = myism....

create table ...as select

create table ...like

2.表的修改

alter table class130 add column age int default 25;

alter table class130 drop column age;

alter table class130 modify id not null auto_increment;

alter table class130 change id new_id int not null auto_increment;

alter table class130 add primary key(id);

alter table class130 drop primary key;

3.表的改名

rename table class130 to newname;

4.表的刪除

drop table [if exists] class130;

5.表的描述

desc table_name;

show create table table_name;

三.操作表資料

1.插入表資料

insert into table_name[(column_name),...] values(column_name_value,...);

insert into table_name set column_name=column_name_value,...;

2.更新表資料

update table_name set column_name=column_name_value [where ...] [order by ...][limit ...]

3.刪除表資料

delete from table_name[where ...] [order by ...] [limit ...]

truncate [table] table_name;  //刪除表中所有的資料

mysql5 0基礎語句 mysql基礎語句(一)

一 登入 退出 退出 quit 或 exit 二 備份 恢復資料庫 備份資料庫 在mysql服務外面執行 mysqldump h伺服器位址 u登入名 p 要備份的資料庫名 要儲存為的檔案 恢復資料庫 mysql h伺服器位址 u登入名 p埠號 p 資料庫名 注意 通常該資料庫名是需要先建立 存在 三...

mysql5 0基礎語句 MySQL基礎語句

檢視語句 檢視所有資料庫 show databases 檢視表結構 desc table name 檢視庫中所有表 show tables 檢視建表語句 show create table 新建表語句 新建表 id int unsigned not null auto increment comme...

MySQL基礎語句

從 網上乙個教程 簡單來說sql 是用於訪問和處理資料庫的標準的計算機語言,詳細參見 sql 維基百科 sql w3school 基礎語句 注釋 sql 語句對大小寫不敏感。select 等效於 select。sql select 語句select 語句用於從表中選取資料,結果被儲存在乙個結果表中 ...