我有一个查询我想运行以创建表用户,但在执行查询时出现此错误:Started executing query at Line 1
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '
'。
总执行时间:00:00:00.031`
这是我的查询:
CREATE TABLE `users` (
`id` int(8) unsigned NOT NULL AUTO_INCREMENT,
`login` varchar(30) NOT NULL,
`password` varchar(32) NOT NULL,
`secret` varchar(16) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `login` (`login`)
);
有人能让我知道为什么在运行我的查询时出现此错误?
答案 0 :(得分:1)
您正在尝试在SQL服务器上运行MySQL语法。
这是重写的SQL-Server语法。
SQL-server不支持反引号(')所以我删除了它们。
SQL-server不支持AUTO_INCREMENT,而SQL-server正在使用IDENTITY。
SQL服务器不支持unsigned,所以我删除了它。
SQL-server不支持int(8)所以我只将它改为int。
CREATE TABLE users (
id int NOT NULL IDENTITY(1,1),
login varchar(30) NOT NULL,
password varchar(32) NOT NULL,
secret varchar(16) NOT NULL,
CONSTRAINT PK_ID PRIMARY KEY (id),
CONSTRAINT UK_login UNIQUE (login)
);
修改强>
命名索引。
Traceback (most recent call last):
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 808, in __init__
self.do_handshake()
File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda\envs\seatgeek\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.seatgeek.com', port=443): Max retries exceeded with url: (Caused by SSLError(SSLError(1, '[SSL: CERT
IFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),))
import requests
with open("id.txt","r") as file:
read_data = file.readlines()
client_id_data = read_data[1]
CLIENT_ID = client_id_data
payload = {'performers[home_team].slug': 'warriors','client_id':
CLIENT_ID}
response = requests.get('https://api.seatgeek.com/2/events', verify = True,
params=payload)
答案 1 :(得分:1)
我认为您尝试在MySql
中使用Sql Sever
语法,Sql server
因使用(`)字符而引发错误。
使用此示例中的syntax
:
<强> MySQL的:强>
CREATE TABLE Persons (
ID int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
UNIQUE (ID),
PRIMARY KEY (ID)
);
SQL Server:
CREATE TABLE Persons (
ID int NOT NULL IDENTITY(1,1),
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
CONSTRAINT PK_Person_ID PRIMARY KEY (ID),
CONSTRAINT UC_Person_LastName UNIQUE (LastName)
);