mysql用變數名建立表 MySQL變數表命名建立

2021-10-17 22:26:48 字數 1091 閱讀 6381

我正在為minecraft建立乙個伺服器集合的資料庫,以及我設定它的方式,我希望在新增時為每個伺服器建立乙個表.目前,除了我無法獲取正在建立的包含ip位址的表之外,我還能正常工作.我希望**類似於[ip] _players,其中[ip]被實際的ip位址替換,它將通過正在建立的函式傳送.這是我到目前為止:

delimiter $$

create procedure `minecraft`.`addserver` (ip text)

begin

declare play text;

declare tran text;

set play = ip + '_players';

set tran = ip + '_transactions';

insert into `minecraft`.`server_data` (`server_ip`) values (ip);

create table `minecraft`.play (

`player` text not null ,

`balance` double not null default 100 ,

`warnings` int not null default 0 ,

`offences` int not null default 0 ,

unique index `player_unique` (`player` asc) );

create table `minecraft`.tran (

`time` timestamp not null ,

`player` text not null ,

`destination` text not null ,

`amount` double not null ,

`description` text not null ,

primary key (`time`) );

end而不是將其建立為192.168.001.107_players時

call minecraft.addserver(『192.168.001.107』);

預先形成,它建立乙個名為play的表.

我究竟做錯了什麼?

python建立變數名軟體 動態建立變數名

我有這段 來建立乙個介面和一些按鈕 maya中的python class mrshadowmapchangerui def init self smattrs shadowmap smapresolution smapsamples smapsoftness smapbias smniceattrs...

動態建立變數名

問題 你想要動態地建立乙個變數名.例如,你想要使用與資料庫查詢得到的字段稱一致的變數名.方案 使用php中 可變變數 的語法,即在乙個其值為你想作為變數名稱的變數前面加乙個 animal turtles turtles 103 print animal 討論 如果在乙個變數名稱前面放兩個美元 符號,...

thinkphp 用變數名代替類名

思路是用命名空間加型別名合併成乙個字串 需要用來代替類名的變數 usertype user 合併完整的類名,注意轉義字元的用法,下面的路徑可以代替為自己的模型檔案路徑 用這個字串就能完美代替想要的模型的名稱了 result classname get id 如果覺得不好理解,也可以用這個字串例項化乙...