0

I am learning mysql myself but I faced this problem with my server when I want to create a simple table.

CREATE TABLE customers (first_name 'NOT NULL',last_name 'NOT NULL',age);

Error:

ERROR 1064 (42000): 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 ''NOT NULL',last_name 'NOT NULL',age)' at line 1

I have no idea what is the problem as this command was learnt from website, it should have been fine to use the NOT NULL.

my sql server is 8.0.22
Community
  • 1
  • 1
  • 1
    `CREATE TABLE customers (first_name varchar(20) NOT NULL, last_name varchar(20) NOT NULL, age int);` – The Impaler Mar 14 '23 at 13:12
  • Quite a lot of spurious quotes in there..if you got that from web site don't trust it. – P.Salmon Mar 14 '23 at 17:01
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – P.Salmon Mar 14 '23 at 17:02
  • 'NOT NULL' is a string vs NOT NULL is a value – easleyfixed Mar 15 '23 at 21:09
  • Also this is weird, how would it create NOT NULL as a default value? It needs a value to not be null .. try setting them default to NULL .. or do you mean you dont want nulls at all in that case set default to EMPTY or '' instead – easleyfixed Mar 15 '23 at 21:10
  • PRO TIP - use Workbench and save yourself these types of headaches .. its like you can do it by hand if you want but its like using Word as a Spread Sheet .. its possible its just MUCH more time consuming... citation ->https://dev.mysql.com/downloads/workbench/ – easleyfixed Mar 15 '23 at 21:12

0 Answers0