国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql 常用命令集錦(Linux/Windows)

2024-07-24 12:47:03
字體:
來源:轉載
供稿:網友

  查看數據庫狀態:service mysqld status

  啟動數據庫:service mysqld start

  進入數據庫:mysql -u root -p123456;

  列出數據庫:show databases;

  選擇數據庫:use databaseName;

  列出表格:show tables;

  顯示表格列的屬性:show columns from tableName;

  建立數據庫:source fileName.txt;

  匹配字符:可以用通配符_代表任何一個字符,%代表任何字符串;

  增加一個字段:alter table tabelName add column fieldName dateType;

  增加多個字段:alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;

  多行命令輸入:注意不能將單詞斷開;當插入或更改數據時,不能將字段的字符串展開到多行里,否則硬回車將被儲存到數據中;

  增加一個管理員帳戶:grant all on *.* to user@localhost identified by "password";

  每條語句輸入完畢后要在末尾填加分號';',或者填加'/g'也可以;

  查詢時間:select now();

  查詢當前用戶:select user();

  查詢數據庫版本:select version();

  查詢當前使用的數據庫:select database();

  1、刪除student_course數據庫中的students數據表:

rm -f student_course/students.*

  2、備份數據庫:(將數據庫test備份)

mysqldump -u root -p test>c:/test.txt

  備份表格:(備份test數據庫下的mytable表格)

mysqldump -u root -p test mytable>c:/test.txt

  將備份數據導入到數據庫:(導回test數據庫)

mysql -u root -p test

  3、創建臨時表:(建立臨時表zengchao)

create temporary table zengchao(name varchar(10));

  4、創建表是先判斷表是否存在

create table if not exists students(……);

  5、從已經有的表中復制表的結構

create table table2 select * from table1 where 1<>1;

  6、復制表

create table table2 select * from table1;

  7、對表重新命名

alter table table1 rename as table2;

  8、修改列的類型

alter table table1 modify id int unsigned;//修改列id的類型為int unsigned alter table table1 change id sid int unsigned;//修改列id的名字為sid,而且把屬性修改為int unsigned

  9、創建索引

alter table table1 add index ind_id (id); create index ind_id on table1 (id); create unique index ind_id on table1 (id);//建立唯一性索引
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 山阳县| 都兰县| 弥渡县| 衢州市| 呼图壁县| 阿巴嘎旗| 谢通门县| 资源县| 东乡族自治县| 马山县| 八宿县| 滨海县| 安顺市| 长顺县| 巴林左旗| 滨州市| 大余县| 汽车| 北川| 嘉定区| 巧家县| 青海省| 墨江| 开化县| 漳浦县| 资讯 | 涿州市| 芦山县| 维西| 江门市| 昔阳县| 迭部县| 光泽县| 岳阳市| 佛山市| 云龙县| 肥东县| 离岛区| 黄大仙区| 江油市| 遂溪县|