日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

mySQL笔记(1)

發(fā)布時(shí)間:2023/11/27 生活经验 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mySQL笔记(1) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.show databases; ? ? 顯示所有數(shù)據(jù)庫(kù)

2.create database 數(shù)據(jù)庫(kù)名 ?[其他選項(xiàng)]; ? ? 新建數(shù)據(jù)庫(kù)

? ? 例:create database example_db ?character set gbk; ?創(chuàng)建了一個(gè)名為example_db的數(shù)據(jù)庫(kù),并將數(shù)據(jù)庫(kù)字符編碼指定為gbk,便于在命令提示符下顯示中文。

3.use 數(shù)據(jù)庫(kù)名; ?選擇要用的數(shù)據(jù)庫(kù)

4.show tables; ? ? 顯示已選擇的數(shù)據(jù)庫(kù)中的所有表

5.create table 表名(列名 ?數(shù)據(jù)類型,........); ? ?創(chuàng)建表

? ? 例:create table students(

? ? ? ? ? ? ? ? ? id ? int ? ?not null ? ?primary key,

? ? ? ? ? ? ? ? ?name ?char(8) ?not null,

? ? ? ? ? ? ? ? ?password ?varchar(20)?

); ? ? ? ? ? ? ?

6.alter table 表名 ?add ?要插入的列名稱 ? 數(shù)據(jù)格式 ?[after 插入位置];; ? ? ? ? ? ?在建好的表中插入一列

? ? ?例:alter table students add tel varchar(13) ?after password;

7.alter table 表名 ?drop column ?要?jiǎng)h除的列名稱; ? ? ? ? ? ? ?在建好的表中刪除一列

? ? ?例:alter table students drop column tel;

8.insert 【into】 表名(列名1,列名2,......)values(列值1,列值2,......); ? ? ?在表中插入數(shù)據(jù)

? ? 例:insert into students(id,name) values(01,'李明');

? ? ? ? ? ?或 insert students values(01,'李明','qwe123');

9.select * from 表名 where 查詢條件; ? ? ? 查詢滿足條件的表中的所有信息

? ?select 列名 from 表名 where 查詢條件; ? ? ? 查詢滿足條件的所有列信息

? ? 例:select id,name ?from students;

10.update 表名 set 列名=新值 where ?更新條件; ?修改表中的數(shù)據(jù)

? ? 例:update students set id=id+1 where name='李明';

11.delete from 表名 ?where 刪除條件;

? ? 例:delete ?from ?students ?where name='李明';

12.drop table 表名; ? ? 刪除整張表

13.drop database 數(shù)據(jù)庫(kù)名; ? ? 刪除整個(gè)數(shù)據(jù)庫(kù)

14.alter table 表名 change 列名 列新名稱 新數(shù)據(jù)類型; ? ? 修改列

? ? 例:alter table students change password password char(10) not null;

15.alter table 表名 rename 新表名; ? ? ? 重命名表

?

注:參考http://www.cnblogs.com/mr-wid/archive/2013/05/09/3068229.html

?

轉(zhuǎn)載于:https://www.cnblogs.com/lifan94/p/4675112.html

總結(jié)

以上是生活随笔為你收集整理的mySQL笔记(1)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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