HustOJ二次开发常用Sql语句

#修改文件或者文件夹权限
sudo chmod 666 myfile||myfolder (可读写)
sudo chmod 644 myfile||myfolder  (只读)


#进入mysql
#先进入root用户
mysql -u root -p

show databases;
use mydb;
show tables;
desc mytable;


#更新表密码
update users set password="yOp4LPKXV5yWY3r3gqnm/j6UBbJhODgx" where user_id ="admin";
update users set school="dhaa1901" where user_id="196197";
update users set user_id="dhccKyc" where user_id ="dhkyc";
update contest set school="dhcc1919" where contest_id =1003;
#设置utf8
#查询编码
mysql> show variables like 'character%'
#修改数据库、表:
ALTER DATABASE `jol` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `users` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;


#导入数据
LOAD data local infile '/home/you/1901user5.txt' into table users fields terminated by '\t' lines terminated by '\r\n';
LOAD data local infile '/home/you/Downloads/2020OI00.txt' into table users fields terminated by '\t' lines terminated by '\r\n';
LOAD data local infile '/home/you/Downloads/2021user003.txt' into table users fields terminated by '\t' lines terminated by '\r\n';
LOAD data local infile '/home/you/Downloads/2021user003-1.txt' into table users fields terminated by '\t' lines terminated by '\r\n';
#删除数据
delete from users where user_id = "195006";
delete from users where user_id = "dhccadmin";
delete from users where school = "dhuu2099";
delete from privilege where rightstr != "administrator" or rightstr != "source_browser" ;
#退出
quit;

ALTER TABLE solution DROP file_path;

ALTER TABLE solution ADD rec text;
ALTER TABLE solution ADD file_path text;

//最近20天的提交记录
select solution_id, nick,time,memory,in_date,contest_id from solution where (TO_DAYS(NOW())-TO_DAYS(in_date)<20) order by solution_id desc;

 

posted on 2022-04-29 10:12  幽遇  阅读(140)  评论(0编辑  收藏  举报