登录
首页 >  数据库 >  MySQL

鏁版嵁搴撶瑪璁?馃搾 MySQL鍩虹鎿嶄綔鍛戒护 鍒嗙被娓呮櫚

来源:SegmentFault

时间:2023-02-24 17:15:25 490浏览 收藏

大家好,今天本人给大家带来文章《鏁版嵁搴撶瑪璁?馃搾 MySQL鍩虹鎿嶄綔鍛戒护 鍒嗙被娓呮櫚》,文中内容主要涉及到鏁版嵁搴?/a>mysql,如果你对数据库方面的知识点感兴趣,那就请各位朋友继续看下去吧~希望能真正帮到你们,谢谢!

MySQL 鍩虹鎿嶄綔鍛戒护锛屽寘鎷鏁版嵁搴撱€佹暟鎹〃銆佹暟鎹殑鎿嶄綔銆?/blockquote>

涓€銆佸搴撶殑鎿嶄綔

1.1 鏌ョ湅

show schemas/databases;

1.2 閫夋嫨搴?/p>

use demo;

1.3 鍒涘缓

create database/schema demo;

1.4 鍒犻櫎

drop database/schema demo;

浜屻€佸琛ㄧ殑鎿嶄綔

2.1 鏌ョ湅

show tables;

2.2 鍒涘缓

create table if not exists job(
    -> id int not null auto_increment,
    -> job_name varchar(50) not null,
    -> job_desc varchar(200) not null,
    -> primary key (id));

2.3 鍒犻櫎

drop table job;

2.4 娓呯┖琛ㄦ暟鎹?/p>

delete from job;

2.5 琛ㄥ瓧娈垫搷浣?/h4>

2.5.1 鏌ョ湅琛ㄥ瓧娈?/p>

desc job;
鎴栬€?show create table job;

2.5.2 澧炲姞琛ㄥ瓧娈?add

alter table job add job_desc varchar(200);

2.5.3 淇敼琛ㄥ瓧娈?change,淇敼琛ㄥ瓧娈电被鍨嬪強鍚嶇О锛歮odify

alter table job change job_desc job_text varchar(200);
alter table job modify job_name varchar(50);

2.5.4 鍒犻櫎琛ㄥ瓧娈?drop

alter table job drop job_desc; 
濡傛灉鏁版嵁琛ㄤ腑鍙墿浣欎竴涓瓧娈靛垯鏃犳硶浣跨敤DROP鏉ュ垹闄ゅ瓧娈?/code>

2.5.5 绉诲姩琛ㄥ瓧娈典綅缃細add鍜宮odify鏃舵墠鍙敤

alter table job add job_desc first; alter table job modify job_desc varchar(200) after id;

3. 鏁版嵁鎿嶄綔

3.1 澧烇細

insert into test.job (job_name,job_desc) values ("鍓嶇宸ョ▼甯?,"鍓嶇寮€鍙憍xx");
insert into test.job values (2,"娴嬭瘯","娴嬭瘯绯荤粺鐨刡ug");
insert into test.job values (5,"鍚庡彴寮€鍙戝伐绋嬪笀","绯荤粺鍚庡彴鏈嶅姟鎺ュ彛鐨勫紑鍙憍xxx");
insert into test.job (job_name,job_desc) values ("缇庡伐","璁捐鐣岄潰UI");

3.2 鍒狅細

delete from job where job_name = "娴嬭瘯";

3.3 鏀?

update job set job_desc = "娴嬭瘯";
update job set job_desc = "鍓嶇娴嬭瘯xxxxx" where job_name = "鍓嶇宸ョ▼甯?;

3.4 鏌?

select job_desc from job where job_name = "test";

终于介绍完啦!小伙伴们,这篇关于《鏁版嵁搴撶瑪璁?馃搾 MySQL鍩虹鎿嶄綔鍛戒护 鍒嗙被娓呮櫚》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布数据库相关知识,快来关注吧!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>