成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專(zhuān)欄INFORMATION COLUMN

數(shù)據(jù)庫(kù)基本操作命令(基礎(chǔ))

PrototypeZ / 1122人閱讀

摘要:數(shù)據(jù)庫(kù)基本操作命令基礎(chǔ)創(chuàng)建一個(gè)用戶(hù),只許本地登錄分配給用戶(hù)操作數(shù)據(jù)庫(kù)的權(quán)限為這個(gè)用戶(hù)分權(quán)所有權(quán)限,這個(gè)權(quán)限只能用在這個(gè)數(shù)據(jù)庫(kù)的所有數(shù)據(jù)表上讓權(quán)限生效找出在這個(gè)數(shù)據(jù)里的這個(gè)表里邊的字段里的所有信息查看數(shù)據(jù)庫(kù)里邊數(shù)據(jù)表里邊的所有字段查看數(shù)據(jù)表里

數(shù)據(jù)庫(kù)基本操作命令(基礎(chǔ))

創(chuàng)建一個(gè)用戶(hù),只許本地登錄

create user "fanxiao2"@"127.0.0.1" identified by "123456"

分配給用戶(hù)操作數(shù)據(jù)庫(kù)的權(quán)限

為fanxiao2這個(gè)用戶(hù)分權(quán)所有權(quán)限,這個(gè)權(quán)限只能用在fanxiao2這個(gè)數(shù)據(jù)庫(kù)的所有數(shù)據(jù)表上

grant all privileges on fanxiao2.* to [email protected];

讓權(quán)限生效

flush privileges;

找出在Mysql這個(gè)數(shù)據(jù)里的user這個(gè)表里邊的user字段里的所有信息

select user form mysql.user

查看mysql數(shù)據(jù)庫(kù)里邊user數(shù)據(jù)表里邊的所有字段

desc mysql.user;

select user, host, password form mysql.user;

查看Mysql數(shù)據(jù)表里用戶(hù)的權(quán)限

select user, select_priv form mysql.user;

查看特定數(shù)據(jù)表里用戶(hù)的權(quán)限

select user, db, select_priv form mysql.db;

查詢(xún)fanxiao2 這個(gè)用戶(hù)被授予的所有數(shù)據(jù)庫(kù)權(quán)限

show grants for [email protected]

吊銷(xiāo)fanxiao2 這個(gè)用戶(hù)的某些權(quán)限

revoke update, delete on fanxiao2.* from [email protected];

執(zhí)行完命令之后可以查看當(dāng)前所擁有的權(quán)限

select user, db, update_priv, delete_priv from mysql.db;

為fanxiao2這個(gè)用戶(hù)設(shè)置一個(gè)新的密碼

set password for [email protected] = password("toor");

刪除用戶(hù)

drop user [email protected];

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

show databases; 查看數(shù)據(jù)庫(kù)

create database fanxiao2;
或者
create database if not exists fanxiao2; 

這條命令會(huì)返回創(chuàng)建數(shù)據(jù)庫(kù)是出現(xiàn)的錯(cuò)誤
刪除數(shù)據(jù)庫(kù)

drop database fanxiao2;

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

先創(chuàng)建一個(gè)范小二數(shù)據(jù)庫(kù)

create database fanxiao2;

切換到范小二數(shù)據(jù)庫(kù)里

use fanxiao2;

查看數(shù)據(jù)表

show tables;

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

create table users(
    username int(11),
    password varchar(255),
);

添加數(shù)據(jù)表中的數(shù)據(jù)欄

新添加的數(shù)據(jù)欄會(huì)出現(xiàn)在數(shù)據(jù)表的最前面

alter table users add id INT(11) first;

添加數(shù)據(jù)欄讓它出現(xiàn)在password數(shù)據(jù)欄的下面

alter table users add username TEXT after password;

添加id數(shù)據(jù)欄為主鍵

alter table users add PRIMARY KEY (id);

修改數(shù)據(jù)欄(修改數(shù)據(jù)欄中id為user_id)

alter table users change id user_id INT(11);

修改數(shù)據(jù)表名字

alter table users rename to fanxiao2user;

刪除數(shù)據(jù)欄

刪除fanxiao2user 這個(gè)數(shù)據(jù)表中的username 數(shù)據(jù)欄

alter table fanxia2user drop username;

新建一個(gè)測(cè)試

重新創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)

create database xiao2 charset=utf8;

進(jìn)入數(shù)據(jù)庫(kù)

use xiao2

創(chuàng)建數(shù)據(jù)表并添加字段

create table users(
    user_id INT(11) unsigned not null auto_increment,
    username VARCHAR(100),
    userpass VARCHAR(255),
    primary key(user_id)
)default charset=utf8;

查看表字段

describe users;

插入數(shù)據(jù)記錄

進(jìn)入數(shù)據(jù)表

use users;

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

insert init users values(null, "fanxiao2", "123456");

插入數(shù)據(jù)表具體的欄

insert into users (username, userpass) values ("fanxiao2test", "12345678");

查詢(xún)數(shù)據(jù)

查看所有的數(shù)據(jù)記錄

select * from users;

指定查詢(xún)某個(gè)字段數(shù)據(jù)

select username from users;

限制查詢(xún)條件

select * from users where username = "fanxiao2";

查詢(xún)數(shù)據(jù)后按照排序顯示

select * from users order by username desc;(升序排序)
select * from users order by username asc;(降序排序)

原文轉(zhuǎn)載至我的個(gè)人博客,歡迎轉(zhuǎn)載:數(shù)據(jù)庫(kù)基本操作命令-基礎(chǔ)

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/17597.html

相關(guān)文章

  • 《聊聊mongodb》系列二 mongoDB存儲(chǔ)結(jié)構(gòu)以及基礎(chǔ)的shell命令

    摘要:進(jìn)入數(shù)據(jù)庫(kù),然后查看擁有的集合查看當(dāng)前操作的數(shù)據(jù)庫(kù),以及數(shù)據(jù)庫(kù)版本,連接及端口號(hào)以下部分為創(chuàng)建數(shù)據(jù)庫(kù),我們剛創(chuàng)建的數(shù)據(jù)庫(kù)并不在數(shù)據(jù)庫(kù)的列表中,要顯示它,我們需要向數(shù)據(jù)庫(kù)插入一些數(shù)據(jù)。 跟著上一節(jié),我們簡(jiǎn)單了解了下,什么是mongoDB? 這一節(jié),我們簡(jiǎn)單的了解下mongodb的存儲(chǔ)結(jié)構(gòu)以及基礎(chǔ)的shell命令。 一、mongodb的存儲(chǔ)結(jié)構(gòu) 接觸mongodb之前,我們使用的都是關(guān)系型...

    Jacendfeng 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<