Skip to Content
SnippetsSQL Snippets

SQL Snippets

Common SQL patterns for FiveM databases.

User Table

CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, identifier VARCHAR(50) UNIQUE NOT NULL, name VARCHAR(100) NOT NULL, money INT DEFAULT 0, bank INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_identifier (identifier) );

Items Table

CREATE TABLE items ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) UNIQUE NOT NULL, label VARCHAR(100) NOT NULL, weight DECIMAL(10,2) DEFAULT 0, INDEX idx_name (name) );

Inventory Table

CREATE TABLE inventory ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, item_name VARCHAR(50) NOT NULL, count INT DEFAULT 1, FOREIGN KEY (user_id) REFERENCES users(id), INDEX idx_user_id (user_id) );
Last updated on