sql

ERROR 1005: Can't create table. Guru respond

Created one table: CREATE TABLE art ( art_id INT PRIMARY KEY art_name VARCHAR(20)); And this is the second request: CRE ... or: ERROR 1005 (HY000): Can't create table 'set_default_test.craft' (errno: 150) Question: What did I do wrong? Thank you.

How to optimize an sql query (a sample of 1.5 M rows)?

I select data between two dates with the number of rows more than a million with this query: SELECT time AT TIME ZONE 'UTC ... ion time: 5414.691 ms The query runs for 9-13 seconds (although explain shows 5.5). Is there any way to optimize the query?

Difference between FOREIGN KEY and FOREIGN KEY constraint

The MySQL documentation says the following: MySQL supports foreign keys, which let you cross-reference related data acro ... reference related data across tables" and "which help keep this spread-out data consistent" difference I don't understand it)

Complex SQL query

Good time of day. There is a database that contains citizens and their categories. Citizens can have several categories (cate ... T EXISTS (SELECT table.fam FROM table WHERE table.kat BETWEEN 100 AND 150) Where fam is a surname and kat is a category.

SQL query with NULL in WHERE

Hello everyone. There is a categories table, it has parent categories, i.e. those in which parent_id = NULL. Why does the following query return 0 rows? SELECT * FROM categories WHERE parent_id = NULL

MySQL: how to combine values from different columns in one?

There is a table in which the values are scattered across two columns. If there is no value in one column, then it must be in ... | обл | +------+------------------------------------------+---------------+ Thanks!

SQL Select greater than or equal to

Hello! Please help me understand There is a table with a column price (type int) in it records 50, 75, 100... I try to output ... HERE price >= 51 AND price <= 100 price BETWEEN 51 AND 100 doesn't work either I only get 100, what's the problem?

Nested transactions SQL server

Hello. The situation is as follows. There is SQL Server 2008, the program uses the QODBC3 driver. Connection is established, ... st(); qDebug() << "Transaction Count "<< Num << ": " <<query->value(0).toInt(); Num++; }

Converting the DATE data format from one type to another in MS SQL, for example dd. mm. yyyy to mm. dd.yyyy

Is it possible to convert dates of the form dd.mm.yyyy to the form mm.dd.yyyy. For example, there is a column in a table with ... tibility of date representation types, respectively, we would like to immediately bring them to the default form mm.dd.yyyy.

MySQL indexes and data sampling acceleration

A simple data table is created: CREATE TABLE IF NOT EXISTS `table_1` ( id INT NOT NULL AUTO_INCREMENT, user_id INT( ... pecifically only those records that meet the search conditions (user_id = 28572), without affecting the rest of the records?

Export data from TXT to Excel by criteria

There are.A txt file that has 900 million rows, broken down into columns. From this file, you need to get about 200k rows and upload them to Excel by the ID in one of the columns. How can this be done technically? It is possible that using SQL

SQL query optimization or denormalization?

The problem lies in the fact that the query to the database is executed for an extremely long time (up to 400 ms) SELECT ... ex Cond: (id = production_product_categories.product_id) Filter: (manufacturer_id = 15)

Working with XML in MS SQL?

Let's say there is an XML of this type: <root> <TableRow> <field1></field1> <field2></field ... ithout explicitly listing the node names? Let's say it is known that all nodes are field+digit. Can I make a request by mask?

Correct SQL UPDATE query in PHP

How do I write a proper query to update certain words in the wp_post table? Code that updates words: UPDATE wp_posts SET po ... { printf("Все ок.\n"); } } while ($mysqli->next_result()); } /* закрываем соединение */ $mysqli->close();

How to link 3 tables in an SQL query?

Hello, how do I link 3 tables in an SQL query ? I have such a query (links 2 tables) SELECT categories.title, goods.name, go ... ---|------------- id(Pk) | id(Pk) | id(Pk) title | name | items_id ---- | category | ---

Data types in PostgreSQL

Before that, I made a database on the MySQL DBMS, decided to master PostgreSQL, and saw that there are no data types that are ... rds in MySQL will weigh 17 gigabytes, and in PostgreSQL will weigh twice as much? Shed some light on this situation. Thanks.

Non-strict tag search in PostgreSQL

There is a table of users and a directory of user properties (tags). They relate to each other as many to many, i.e. there is ... can do everything anything, by and large, even the use of Postgres is not mandatory. But the solution must be used by NodeJS.

Recommend an IDE for working in Oracle

I'm just starting to get acquainted with Oracle and as I understood after installing the batteries are not included. What ID ... paid solutions. Previously, I worked with MS SQL through MS Management Studio, I would like something similar under Oracle.

What is the syntax for the functional analog of SELECT TOP(N) in Oracle?

Suppose there is a table TABLE ID | DEF 1 | Один 2 | Два 3 | Три 4 | Четыре Then the query in MS SQL Server SELECT TO ... give us the output: ID | DEF 2 | Два 1 | Один How do I get a really similar syntax for Oracle in terms of functionality?

Competent protection against SQL-Injection

For a long time I have been tormented by the question: How to protect your site from SQL-Injection. In the old days, I used ... atabase data " , the connection is the same as specified in the article. How can you protect yourself from these injections?