常用的mysql語句

2021-08-26 08:30:34 字數 1046 閱讀 2623

#delimiter $ 宣告乙個分隔符 $

#結束時也要呼叫多一次 $

##################拼接字串,concat_ws(分隔符,第乙個字串,第二個字串)

#例子: concat_ws(i,'','.mp4?x-oss-process=video/snapshot,t_1000,m_fast,w_220,h_300')

##################獲取當前時間戳,unix_timestamp(now())

##################獲取 min 到 max 的隨機數 floor(min + rand() * (max - min + 1))

##################獲取 1 到 35 的隨機數 floor(1 + rand() * (35 - 1 + 1))

drop procedure if exists pwhile;

delimiter $;

create procedure pwhile()

begin

declare i int;

set i = 6123;

while i <= 6135 do

insert into user_video(user_id,cdn_video_url,cdn_thumb_img ,city,addtime,click_count,is_show) value ((i-759),concat_ws(i,'http://你cdn的網域名稱/user_video/2018/08-29/','.mp4'),concat_ws(i,'http://你cdn的網域名稱/user_video/2018/08-29/','.mp4?x-oss-process=video/snapshot,t_1000,m_fast,w_220,h_300'),0,unix_timestamp(now()),floor(1 + rand() * (35 - 1 + 1)),1);

set i = i+1;

end while;

end;

$;call pwhile();

常用mysql語句 常用MySql語句

新建資料表 drop table if exists ga game way create table ga game way id int 11 unsigned not null auto increment comment id primary key id using btree,主鍵 un...

MySql常用的語句

1.複製表結構和資料,但是不複製索引和外來鍵 create table a select from b 2.複製表結構和索引和外來鍵,不複製資料 create table a like b 3.只複製資料 insert into a select from b 4.移動表到另乙個庫 rename t...

常用MySQL語句

1.庫的操作 2.表的操作 3.索引的操作 4.檢視的操作 5.資料的操作 建立資料庫 create database database name 檢視資料庫 show databases 選擇資料庫 use database name 刪除資料庫 drop database database na...