成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

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

PrototypeZ / 1129人閱讀

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

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

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

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

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

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

grant all privileges on fanxiao2.* to fanxiao2@127.0.0.1;

讓權(quán)限生效

flush privileges;

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

select user form mysql.user

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

desc mysql.user;

select user, host, password form mysql.user;

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

select user, select_priv form mysql.user;

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

select user, db, select_priv form mysql.db;

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

show grants for fanxiao2@127.0.0.1

吊銷fanxiao2 這個(gè)用戶的某些權(quán)限

revoke update, delete on fanxiao2.* from fanxiao2@127.0.0.1;

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

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

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

set password for fanxiao2@127.0.0.1 = password("toor");

刪除用戶

drop user fanxiao2@127.0.0.1;

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

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

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

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

drop database fanxiao2;

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

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

create database fanxiao2;

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

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ù)庫

create database xiao2 charset=utf8;

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

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");

查詢數(shù)據(jù)

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

select * from users;

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

select username from users;

限制查詢條件

select * from users where username = "fanxiao2";

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

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

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

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

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

相關(guān)文章

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

    摘要:進(jìn)入數(shù)據(jù)庫,然后查看擁有的集合查看當(dāng)前操作的數(shù)據(jù)庫,以及數(shù)據(jù)庫版本,連接及端口號(hào)以下部分為創(chuàng)建數(shù)據(jù)庫,我們剛創(chuàng)建的數(shù)據(jù)庫并不在數(shù)據(jù)庫的列表中,要顯示它,我們需要向數(shù)據(jù)庫插入一些數(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)論

PrototypeZ

|高級(jí)講師

TA的文章

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