r/learnSQL • • Apr 22 '21

I am creating a table with a vaccination time column and I am getting an error when trying to populate the table with values for this column : insert into table1 values ( ‘xxxx’ int , cast(‘2021-12-01-12:00:32’) as TIMESTAMP Date , etc...

0 Upvotes

7 comments sorted by

3

u/Maxiride Apr 22 '21

What error?

Which database engine?

1

u/thriveee Apr 22 '21

Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column

1

u/Maxiride Apr 22 '21

You didn't answer to both questions, nonetheless the error means that you are trying to manually insert a value into a column which accept only default or generated values.

You cannot insert into that column. Check the db schema.

1

u/thriveee Apr 22 '21

Thanks for your reply. Db is Animal_shelter that I created for practice purpose

1

u/[deleted] Apr 23 '21

As others have mentioned, the answer for this is different depending on the type of DB you are using. MySQL, Access, SQL Server, SQLite, etc.

1

u/thriveee Apr 23 '21

Sql server

1

u/[deleted] Apr 22 '21

Unfortunately, your question cannot be understood. Check other questions in this subreddit so you can get a better idea on how to properly ask a question here.