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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

mySQL笔记(1)

發布時間:2023/11/27 生活经验 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mySQL笔记(1) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.show databases; ? ? 顯示所有數據庫

2.create database 數據庫名 ?[其他選項]; ? ? 新建數據庫

? ? 例:create database example_db ?character set gbk; ?創建了一個名為example_db的數據庫,并將數據庫字符編碼指定為gbk,便于在命令提示符下顯示中文。

3.use 數據庫名; ?選擇要用的數據庫

4.show tables; ? ? 顯示已選擇的數據庫中的所有表

5.create table 表名(列名 ?數據類型,........); ? ?創建表

? ? 例:create table students(

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

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

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

); ? ? ? ? ? ? ?

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

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

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

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

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

? ? 例: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 ?更新條件; ?修改表中的數據

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

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

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

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

13.drop database 數據庫名; ? ? 刪除整個數據庫

14.alter table 表名 change 列名 列新名稱 新數據類型; ? ? 修改列

? ? 例: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

?

轉載于:https://www.cnblogs.com/lifan94/p/4675112.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。