国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

50天精通Golang(第14天)

這篇具有很好參考價值的文章主要介紹了50天精通Golang(第14天)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、數(shù)據(jù)庫

1.1 數(shù)據(jù)庫 基本知識

DB:

DBMS:

數(shù)據(jù)庫,數(shù)據(jù)表,表的結(jié)構(gòu)。。

DB:是指datebase(數(shù)據(jù)庫)
數(shù)據(jù)庫是存儲數(shù)據(jù)的一個集合,數(shù)據(jù)庫中通常使用數(shù)據(jù)表等組成,而數(shù)據(jù)表是由數(shù)據(jù)的字段和數(shù)據(jù)的值等信息組成。
DBMS:是指datebase mangement systerm(數(shù)據(jù)庫管理系統(tǒng))
它是操作數(shù)據(jù)庫和管理數(shù)據(jù)庫的一個系統(tǒng),比如mysql、sqlserver等都是屬于數(shù)據(jù)庫管理軟件,人們通過這些系統(tǒng)或者工具來管理數(shù)據(jù)庫內(nèi)的數(shù)據(jù)。
DBS:是指datebase systerm (數(shù)據(jù)庫系統(tǒng))
數(shù)據(jù)庫系統(tǒng)又?jǐn)?shù)據(jù)庫和數(shù)據(jù)庫管理軟件等組成,數(shù)據(jù)庫是一個邏輯上的存儲數(shù)據(jù)的概念,而對應(yīng)的是實體是數(shù)據(jù)庫管理軟件存儲存儲在硬盤上的數(shù)據(jù)庫,所以數(shù)據(jù)庫系統(tǒng)包含數(shù)據(jù)庫和數(shù)據(jù)庫管理軟件。

1.2 Mysql的安裝和卸載

1.3 登錄

方式一:DOS窗口:輸入以下命令:

C:\Users\ruby>mysql -u root -p
回車后輸入密碼即可

方式二:通過Mysql的Command Line來登錄:

直接輸入密碼即可

方式三:通過其他的可視化工具軟件:

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

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

//create database [if not exists]數(shù)據(jù)庫名 [default charset utf8 collate utf8_general_ci];
mysql> create database my1905 character set utf8;
Query OK, 1 row affected (0.00 sec)


2.顯示有哪些數(shù)據(jù)庫:

mysql> show databases;

3.切換到數(shù)據(jù)庫:以后的操作都是針對該數(shù)據(jù)庫的,比如建表。。

mysql> use my1905;

4.查看當(dāng)前數(shù)據(jù)庫有哪些數(shù)據(jù)表:

mysql> show tables;

5.刪除數(shù)據(jù)庫:

mysql> drop database if exists my1905;

1.5 數(shù)據(jù)類型

char(10)–>定長的字符串

? "wangergou "

? "abc "

varchar(10)–>變長

? “wangergou”

? “abc”

1.6 數(shù)據(jù)表的操作

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

mysql> create database if not exists my1905 default charset utf8 collate utf8_ge
neral_ci;

2.創(chuàng)建數(shù)據(jù)表:

mysql> create table users(
    -> id int(4) primary key auto_increment,
    -> username varchar(20),
    -> pwd varchar(30));

3.查看表結(jié)構(gòu):desc–>describe

mysql> desc users;

4.顯示檢表語句:

mysql> show create table users;

注意點:

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

mysql:

? database1–>oa

? database2–>bluebird

? 。。。。

2.切換數(shù)據(jù)庫

? use 數(shù)據(jù)庫名

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

mysql>create table test1(

? ->id int(4) auto_increment primary key,

? ->…);

5.插入一條數(shù)據(jù):

mysql> insert into users(id,username,pwd) values(1,'admin','123456');
Query OK, 1 row affected (0.02 sec)

6.查詢數(shù)據(jù):

mysql> select * from users;
+----+----------+--------+
| id | username | pwd    |
+----+----------+--------+
|  1 | admin    | 123456 |
+----+----------+--------+
1 row in set (0.00 sec)

1.7 修改表結(jié)構(gòu)

alter table 表名 xxx。。。

  1. 添加字段:add

    mysql> alter table users add(
        -> age int(4),
        -> birthday date);
    
  2. 修改已有字段的數(shù)據(jù)類型:modify

    mysql> alter table users modify age float(4,1);
    

注意點:并不能隨意的更改已有列的數(shù)據(jù)類型。尤其是表中已經(jīng)有數(shù)據(jù)了

? A:兼容類型:長度可以從小到大,不能已有的數(shù)據(jù)越界。

? B:不兼容類型:varchar–>int,更改失敗。

3.更改列的名字:change

mysql> alter table users change pwd password varchar(30);

?

  1. 刪除某列:drop

    mysql> alter table users drop birthday;
    

如果該列存在數(shù)據(jù),那么數(shù)據(jù)也會被刪掉。

5.表重命名:rename to

mysql> alter table users rename to user2;
mysql> rename table user2 to user3;

6.刪除表:drop table

mysql> drop table user3;

1.8 插入數(shù)據(jù)

1.插入數(shù)據(jù):

insert into 表名(列1,列2,列3.。。) values(值1,值2,值3.。。)

全列插入:如果有所有列都要插入數(shù)據(jù),那么可以省略列的名字

缺省插入:如果有某一個或一些字段沒有數(shù)值,那么就要寫清楚列名和值。

同時插入多行:

1.9 修改數(shù)據(jù)

語法結(jié)構(gòu):

update 表名 set 列1=值1,列2=值2...[where 條件];

where后是修改條件:為true,才會修改數(shù)據(jù)。

運算符:
	=,數(shù)值相等
	!=,<>,數(shù)值不等
	between ... and,區(qū)間
	>
	<
	>=
	<=
	or
	and
	in(值1,值2,值3.。)



1.修改學(xué)號為1006的同學(xué)姓名為陳聰

mysql> update student set name='陳聰' where no=1006;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from student;
+------+--------+------+------+------------+
| no   | name   | age  | sex  | birthday   |
+------+--------+------+------+------------+
| 1001 | 王二狗 |   18 | 男   | 2007-10-10 |
| 1002 | rose   |   19 | 女   | 2006-09-09 |
| 1003 | jack   |   20 | 男   | 2005-08-06 |
| 1004 | 張三   |   18 | 女   | 1990-12-12 |
| 1005 | 李四   |   21 | 男   | 1991-06-08 |
| 1006 | 陳聰   |   22 | 男   | 1992-10-10 |
+------+--------+------+------+------------+
6 rows in set (0.00 sec)

2.年齡小于19歲的同學(xué),性別改為女

mysql> update student set sex='女' where age < 19;
Query OK, 1 row affected (0.01 sec)
Rows matched: 2  Changed: 1  Warnings: 0

mysql> select * from student;
+------+--------+------+------+------------+
| no   | name   | age  | sex  | birthday   |
+------+--------+------+------+------------+
| 1001 | 王二狗 |   18 | 女   | 2007-10-10 |
| 1002 | rose   |   19 | 女   | 2006-09-09 |
| 1003 | jack   |   20 | 男   | 2005-08-06 |
| 1004 | 張三   |   18 | 女   | 1990-12-12 |
| 1005 | 李四   |   21 | 男   | 1991-06-08 |
| 1006 | 陳聰   |   22 | 男   | 1992-10-10 |
+------+--------+------+------+------------+
6 rows in set (0.01 sec)

3.年齡大于等于18歲,并且小于等于19歲的同學(xué)姓名改為馬冬梅

mysql> update student set name='馬冬梅' where age >= 18 and age <= 19;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> select *from student;
+------+--------+------+------+------------+
| no   | name   | age  | sex  | birthday   |
+------+--------+------+------+------------+
| 1001 | 馬冬梅 |   18 | 女   | 2007-10-10 |
| 1002 | 馬冬梅 |   19 | 女   | 2006-09-09 |
| 1003 | jack   |   20 | 男   | 2005-08-06 |
| 1004 | 馬冬梅 |   18 | 女   | 1990-12-12 |
| 1005 | 李四   |   21 | 男   | 1991-06-08 |
| 1006 | 陳聰   |   22 | 男   | 1992-10-10 |
+------+--------+------+------+------------+
6 rows in set (0.00 sec)

4.修改年齡19到20歲之間的同學(xué)姓名為馬春梅:

mysql> update student set name='馬春梅' where age between 19 and 20;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> select * from student;
+------+--------+------+------+------------+
| no   | name   | age  | sex  | birthday   |
+------+--------+------+------+------------+
| 1001 | 馬冬梅 |   18 | 女   | 2007-10-10 |
| 1002 | 馬春梅 |   19 | 女   | 2006-09-09 |
| 1003 | 馬春梅 |   20 | 男   | 2005-08-06 |
| 1004 | 馬冬梅 |   18 | 女   | 1990-12-12 |
| 1005 | 李四   |   21 | 男   | 1991-06-08 |
| 1006 | 陳聰   |   22 | 男   | 1992-10-10 |
+------+--------+------+------+------------+
6 rows in set (0.00 sec)

二、SQL

結(jié)構(gòu)化查詢語言(Structured Query Language)。操作數(shù)據(jù)庫的。

DDL語言:數(shù)據(jù)定義語言(用于定義數(shù)據(jù)的表結(jié)構(gòu))Data Definition Language

? 創(chuàng)建數(shù)據(jù)表:create table 表名

? 修改數(shù)據(jù)表:alter table 表名

? 刪除數(shù)據(jù)表:drop table 表名

DML語言:數(shù)據(jù)操縱語言(用于操作數(shù)據(jù)表中的數(shù)據(jù))DML - Data Mainpulation Language

? 添加數(shù)據(jù):insert

? 修改數(shù)據(jù):update

? 刪除數(shù)據(jù):delete

DQL語言:數(shù)據(jù)查詢語言(專門用于數(shù)據(jù)的查詢)DQL - Data Query Language

? 查詢數(shù)據(jù):select

DCL語言:

三、總結(jié)

數(shù)據(jù)庫:

? 安裝和卸載(看文檔)

? 數(shù)據(jù)庫的登錄:

? 1.dos窗口:mysql命令—>配置環(huán)境變量

? -u 用戶名

? -p 密碼

? 2.mysql的命令行:直接輸入密碼即可

? 3.通過一些可視化工具:比如navicat

1.show databases;

2.create database if not exists my1905 character set utf8;

? default charset utf8 collate utf8_general_ci;

3.use my1905;

4.create table student(id int(4) primary key auto_increment,name varchar(30),sex varchar(2));

5.alter table 表名

? add 列名 數(shù)據(jù)類型

? modify 列名 數(shù)據(jù)類型

? change 原列名 新列名 數(shù)據(jù)類型

? drop 刪除列

6.drop table 表名;

7.insert into 表名(列1,列2,列3.。。) values(值1,值2,值3.。。。)

? 全列插入:

? 同時插入多條:

8.update 表名 set 列1=新值,列2=新值 [where 修改條件];

? where 后 的是表達(dá)式是boolean

? =,!=,<>,>,<,>=,<=,between and, and , or ,not …

? null—> is null ,is not null

9.delete from 表名 where 刪除條件

約束:主鍵,外鍵

查詢:簡單查詢,復(fù)雜,多表文章來源地址http://www.zghlxwxcb.cn/news/detail-783710.html

到了這里,關(guān)于50天精通Golang(第14天)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 100天精通Golang(基礎(chǔ)入門篇)——第15天:深入解析Go語言中函數(shù)的應(yīng)用:從基礎(chǔ)到進(jìn)階,助您精通函數(shù)編程?。ㄟM(jìn)階)

    100天精通Golang(基礎(chǔ)入門篇)——第15天:深入解析Go語言中函數(shù)的應(yīng)用:從基礎(chǔ)到進(jìn)階,助您精通函數(shù)編程?。ㄟM(jìn)階)

    ?? 博主 libin9iOak帶您 Go to Golang Language.? ?? 個人主頁——libin9iOak的博客?? ?? 《面試題大全》 文章圖文并茂??生動形象??簡單易學(xué)!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍》學(xué)會IDEA常用操作,工作效率翻倍~?? ?? 希望本文能夠給您帶來一定的幫助??文章粗淺,敬請批

    2024年02月12日
    瀏覽(36)
  • 100天精通Golang(基礎(chǔ)入門篇)——第12天:深入解析Go語言中的集合(Map)及常用函數(shù)應(yīng)用

    100天精通Golang(基礎(chǔ)入門篇)——第12天:深入解析Go語言中的集合(Map)及常用函數(shù)應(yīng)用

    ?? 博主 libin9iOak帶您 Go to Golang Language.? ?? 個人主頁——libin9iOak的博客?? ?? 《面試題大全》 文章圖文并茂??生動形象??簡單易學(xué)!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍》學(xué)會IDEA常用操作,工作效率翻倍~?? ?? 希望本文能夠給您帶來一定的幫助??文章粗淺,敬請批

    2024年02月12日
    瀏覽(27)
  • 【Golang】Golang進(jìn)階系列教程--Golang中文件目錄操作的實現(xiàn)

    【Golang】Golang進(jìn)階系列教程--Golang中文件目錄操作的實現(xiàn)

    Golang中,文件是指計算機(jī)中存儲數(shù)據(jù)的實體,文件可以是文本文件、二進(jìn)制文件、配置文件等。在Go語言中,通過操作文件,我們可以讀取文件的內(nèi)容,寫入數(shù)據(jù)到文件,以及獲取文件的屬性等。 Golang中的文件可以分為兩種類型:文本文件和二進(jìn)制文件。文本文件是指只包含

    2024年02月15日
    瀏覽(23)
  • Golang -> Golang 變量

    Golang -> Golang 變量

    案例: 第一種:指定變量類型,聲明后若不賦值,使用默認(rèn)值 Golang 的變量如果沒有賦初值,編譯器會使用默認(rèn)值 比如 int 默認(rèn)值 0, string 默認(rèn)值為空串, 小數(shù)默認(rèn)為 0 第二種:根據(jù)值自行判定變量類型(類型推導(dǎo)) , 不使用默認(rèn)值 第三種:省略 var 注意 :=左側(cè)的變量不應(yīng)該是已

    2024年02月11日
    瀏覽(20)
  • 【Golang】一文學(xué)完 Golang 基本語法

    安裝包鏈接:https://share.weiyun.com/InsZoHHu IDE 下載:https://www.jetbrains.com/go/ 每個可執(zhí)行代碼都必須包含 Package、import 以及 function 這三個要素。 主函數(shù)文件: package1 包的文件: 注意:golang是 以首字母大小寫 來區(qū)分對包外是否可見。 所以 Fun() 函數(shù),Str,想要在 main 文件被訪問,

    2024年02月13日
    瀏覽(25)
  • 【Golang】golang使用三方SDK操作容器指南

    【Golang】golang使用三方SDK操作容器指南

    大家好 我是寸鐵?? 總結(jié)了一篇 golang使用三方SDK操作容器? 喜歡的小伙伴可以點點關(guān)注 ?? 這應(yīng)該是目前全網(wǎng)最全golang使用三方SDK操作容器的指南了?? 主要是創(chuàng)建容器的配置信息,常用的字段 使用包如下: 配置創(chuàng)建Docker 容器的結(jié)構(gòu)體,具體字段的含義和用途如下: 1.

    2024年04月11日
    瀏覽(21)
  • golang學(xué)習(xí)-golang結(jié)構(gòu)體和Json相互轉(zhuǎn)換

    1、結(jié)構(gòu)體轉(zhuǎn)為json對象 ? ? v, _ := json.Marshal(student) ? ? jsonStr := string(v) // 結(jié)構(gòu)體轉(zhuǎn)為json對象 2、json字符串轉(zhuǎn)為結(jié)構(gòu)體 ? ? var s1 Student ? ? err := json.Unmarshal([]byte(str), s1) //json 字符串轉(zhuǎn)為結(jié)構(gòu)體 ? ?3、結(jié)構(gòu)體標(biāo)簽 表示的是轉(zhuǎn)換為json對象時,ID字段變?yōu)閕d,Name字段變?yōu)閚ame. type

    2024年01月23日
    瀏覽(24)
  • golang開發(fā)工程師-第一步:golang入門基礎(chǔ)教學(xué)

    golang開發(fā)工程師-第一步:golang入門基礎(chǔ)教學(xué)

    人生格言:好記性不如爛筆頭! 建議:看這篇文章,前提是必須會java,javascript等一門語言。你可以把golang語言看做是縫合怪;集c,java,javascript等語言優(yōu)點于一身。如果你沒有任何編程語言傍身,本人還是建議你去嗶站看視頻,就不要在這里浪費時間了~~~ 優(yōu)勢一:golang代碼

    2024年02月04日
    瀏覽(19)
  • Golang | Leetcode Golang題解之第38題外觀數(shù)列

    Golang | Leetcode Golang題解之第38題外觀數(shù)列

    題目: 題解:

    2024年04月25日
    瀏覽(31)
  • 【oncmdmsg 鼠標(biāo)】2023/8/19 上午9:50:14

    2023/8/19 上午9:50:14 oncmdmsg 鼠標(biāo) 2023/8/19 上午9:50:22 抱歉,您提到的 “oncmdmsg” 和 “鼠標(biāo)” 是什么?請?zhí)峁└嗌舷挛男畔ⅲ覍⒈M力幫助您。 2023/8/19 上午9:51:43 OnCmdMsg 2023/8/19 上午9:52:21 “OnCmdMsg” 是一個在 MFC (Microsoft Foundation Classes) 框架中常見的函數(shù)。它是用于處理窗口消

    2024年02月08日
    瀏覽(19)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包