Query Language Snippets
All Snippets
Cypher
Unknown
Use EXPLAIN to analyze query performance.
EXPLAIN MATCH (p:Person) RETURN p;
Kusto
Unknown
Use render for visualizations.
StormEvents | summarize count() by EventType | render piechart
Redis
Unknown
Use PUBLISH and SUBSCRIBE for pub/sub messaging.
SUBSCRIBE mychannel
PUBLISH mychannel "Hello, world!"
SQL
Unknown
Use EXPLAIN to analyze query performance.
EXPLAIN SELECT * FROM employees WHERE department = 'Sales';
SQL
Update
Add a foreign key constraint to a column.
ALTER TABLE orders ADD CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(id);
SQLAlchemy
Update
Update a record using SQLAlchemy.
user = session.query(User).filter_by(name='Alice').first()
user.age = 31
session.commit()
SQLx
Update
Update a record using SQLx.
sqlx::query!(
r#"
UPDATE users SET age = $1 WHERE name = $2
"#,
31,
"Alice"
)
.execute(&pool)
.await?
Redis
Update
Use EXPIRE to set a key's time to live (TTL).
SET mykey "value"
EXPIRE mykey 60
SQL
Update
Add a unique constraint to a column.
ALTER TABLE users ADD CONSTRAINT unique_email UNIQUE (email);
SQL
Update
Add a column to an existing table.
ALTER TABLE users ADD last_login TIMESTAMP;
SQLModel
Update
Update a record using SQLModel.
with Session(engine) as session:
user = session.exec(select(User).where(User.name == 'Alice')).first()
user.age = 31
session.add(user)
session.commit()
Redis
Update
Increment a counter.
INCR user:1:visits