[Help] Run these queries Sqlite
#1

Run these queries to remove duplicates from the database:

PHP код:
ALTER TABLE Player RENAME TO Player_old
CREATE TABLE Player 
(name TEXT,pass TEXT,ipv4 INTEGER,alive INTEGER,karma INTEGER,regdate INTEGER,lastlog INTEGER,spawntime INTEGER,spawns INTEGER,warnings INTEGER,aimshout TEXT,gpci TEXT)
INSERT INTO Player (name,pass,ipv4,alive,karma,regdate,lastlog,spawntime,spawns,warnings,aimshout,gpciSELECT DISTINCT lower(name),pass,ipv4,alive,karma,regdate,lastlog,spawntime,spawns,warnings,aimshout,gpci FROM Player_old 
I do not know where to start
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
1) There is no need to destroy and recreate the table to remove duplicates.

2) That query is incomplete.

3) Just set a UNIQUE column.
2)
PHP код:
ALTER TABLE Player RENAME TO Player_old
CREATE TABLE Player 
(name TEXT,pass TEXT,ipv4 INTEGER,alive INTEGER,karma INTEGER,regdate INTEGER,lastlog INTEGER,spawntime INTEGER,spawns INTEGER,warnings INTEGER,aimshout TEXT,gpci TEXT)
INSERT INTO Player (name,pass,ipv4,alive,karma,regdate,lastlog,spawntime,spawns,warnings,aimshout,gpciSELECT DISTINCT lower(name),pass,ipv4,alive,karma,regdate,lastlog,spawntime,spawns,warnings,aimshout,gpci FROM Player_old 
I did get to the end, but it can not connect

https://github.com/Southclaw/ScavengeSurvive

img


I do not know how to improve it
Reply
#3

Firstly, SELECT DISTINCT lower(name) is a bad method for what you're doing. Declare the column using a case-insensitive collation and a UNIQUE constraint.

Instead of your current table declaration:
Код:
CREATE TABLE Player (name TEXT, ...)
Use:
Код:
CREATE TABLE Player (
name TEXT NOT NULL UNIQUE COLLATE NOCASE,
pass TEXT NOT NULL,
ipv4 INTEGER NOT NULL,
alive INTEGER DEFAULT 0,
karma INTEGER DEFAULT 0,
regdate INTEGER NOT NULL,
lastlog INTEGER NOT NULL,
spawntime INTEGER DEFAULT 0,
spawns INTEGER DEFAULT 0,
warnings INTEGER DEFAULT 0,
aimshout TEXT DEFAULT "Drop your weapon!",
gpci TEXT NOT NULL,
active INTEGER DEFAULT 1
)
(based on https://github.com/Southclaw/Scaveng...ounts.pwn#L272)

The UNIQUE constraint will also create the index on the name column for you implicitly, so you don't have to declare it separately.

This way, you will never risk duplicate entries. You should modify the table declaration at https://github.com/Southclaw/Scaveng...counts.pwn#L96
Reply
#4

Quote:
Originally Posted by renegade334
Посмотреть сообщение
Firstly, SELECT DISTINCT lower(name) is a bad method for what you're doing. Declare the column using a case-insensitive collation and a UNIQUE constraint.

Instead of your current table declaration:
Код:
CREATE TABLE Player (name TEXT, ...)
Use:
Код:
CREATE TABLE Player (
name TEXT NOT NULL UNIQUE COLLATE NOCASE,
pass TEXT NOT NULL,
ipv4 INTEGER NOT NULL,
alive INTEGER DEFAULT 0,
karma INTEGER DEFAULT 0,
regdate INTEGER NOT NULL,
lastlog INTEGER NOT NULL,
spawntime INTEGER DEFAULT 0,
spawns INTEGER DEFAULT 0,
warnings INTEGER DEFAULT 0,
aimshout TEXT DEFAULT "Drop your weapon!",
gpci TEXT NOT NULL,
active INTEGER DEFAULT 1
)
(based on https://github.com/Southclaw/Scaveng...ounts.pwn#L272)

The UNIQUE constraint will also create the index on the name column for you implicitly, so you don't have to declare it separately.

This way, you will never risk duplicate entries. You should modify the table declaration at https://github.com/Southclaw/Scaveng...counts.pwn#L96
Thank you,errors still occur
Reply
#5

It was a recording error in /Core/Player/Tutorial.pwn

><! thank all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)