日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

mysql(mariadb)常用命令(持续更新ing)

發(fā)布時間:2025/3/21 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql(mariadb)常用命令(持续更新ing) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

目錄

數(shù)據(jù)庫

創(chuàng)建數(shù)據(jù)庫

切換到某個 數(shù)據(jù)庫下

創(chuàng)建表

創(chuàng)建數(shù)據(jù)

更新表中數(shù)據(jù)

查看表結(jié)構(gòu)

重命名表

刪除重復(fù)數(shù)據(jù)

查看前n行數(shù)據(jù)

增加列?

修改列?

主鍵

刪除列

重命名列

mysql導(dǎo)入csv文件:


數(shù)據(jù)庫

創(chuàng)建數(shù)據(jù)庫

create database databaseName;

切換到某個 數(shù)據(jù)庫下

use databaseName;

創(chuàng)建表

create table tableName(dataName dataType); 例如: create table test(date int);

創(chuàng)建數(shù)據(jù)

insert into person (number,name,birthday) values (1,'haha',20160509);

更新表中數(shù)據(jù)

update person set name="xixi" where name="heihei";

查看表結(jié)構(gòu)

desc tableName;

重命名表

alter table t1 rename t2;

刪除重復(fù)數(shù)據(jù)

mysql> CREATE TABLE tmp SELECT last_name, first_name, sex FROM person_tbl GROUP BY (last_name, first_name, sex); mysql> DROP TABLE person_tbl; mysql> ALTER TABLE tmp RENAME TO person_tbl;

查看前n行數(shù)據(jù)

select * from tableName limit n;

增加列?

alter table user add COLUMN new1 VARCHAR(20) DEFAULT NULL; //增加一列,默認(rèn)為空 alter table user add COLUMN new2 VARCHAR(20) NOT NULL;    //增加一列 ,默認(rèn)不能為空 alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(20) not null first;//在開頭添加列

修改列?

alter table user MODIFY new1 VARCHAR(10); //修改一個字段的類型 alter table user CHANGE new1 new4 int;  //修改一個字段的名稱

主鍵

alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);//需要確保添加主鍵的列不能為空。添加主鍵Alter table tablename Drop Primary key;//刪除主鍵

刪除列

alter table t2 drop column c;

重命名列

alter table t1 change a b integer;

mysql導(dǎo)入csv文件:

load data infile '/tmp/test.csv' into table test_info fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';

參考鏈接:

https://blog.csdn.net/csdn10086110/article/details/89500065

https://www.cnblogs.com/Chenshuai7/p/5271445.html

https://www.cnblogs.com/lvdongjie/p/6274392.html

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的mysql(mariadb)常用命令(持续更新ing)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。