怎么解决[SQL]drop table if exists ta_brand; 受影响的行: 0 时间: 0.004s [SQL] create table tb_brand ( id int primaty key auto_increment, brand_name varchar(20), company_name varchar(20), ordered int, description varchar(100), status int ); [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primaty key auto_increment, brand_name varchar(20), company_name varchar(2' at line 3
时间: 2024-01-28 13:02:51 浏览: 36
在你的 SQL 语句中,"primaty" 应该是 "primary",将其拼写更正即可。正确的 create table 语句如下:
```
create table tb_brand (
id int primary key auto_increment,
brand_name varchar(20),
company_name varchar(20),
ordered int,
description varchar(100),
status int
);
```
此外,如果你的 drop table if exists 语句受影响的行为 0,可能是因为该表不存在。你可以通过 show tables 命令来查看当前数据库中存在哪些表。如果表不存在,那么执行 drop table 语句也会受到影响行数为 0 的提示。
相关问题
:DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS错误代码: 1046 No database selected
这个错误代码通常是因为你没有选择当前的数据库。在执行 SQL 语句前,你需要先选择你要操作的数据库,例如:
```
USE your_database_name;
```
然后再执行你的 SQL 语句即可。如果你不知道当前的数据库名称,可以通过以下命令查看所有的数据库:
```
SHOW DATABASES;
```
然后选择你要操作的数据库即可。
public void mo18211a(SQLiteDatabase sQLiteDatabase) { sQLiteDatabase.execSQL("DROP TABLE IF EXISTS table_current_user"); } }
这段代码的作用是删除名为 "table_current_user" 的表,如果表存在的话。具体来说,它使用 `SQLiteDatabase.execSQL()` 方法执行了一个 DROP TABLE 语句,并指定了一个 IF EXISTS 子句,以避免在表不存在时出现异常。
需要注意的是,执行这种操作会永久性地删除表及其所有数据,因此应该在确认不再需要该表时才执行此操作。另外,如果该表与其他表存在关联,也需要注意此操作的影响。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)