0

I have been trying recently to change the default value of a column as described here. The solution I found there requires deleting the default constraint, which requires knowing the name of that constraint.

The problem I am having is that I do not know how to find out the constraint name in MariaDB. In the same post, these solutions were suggested:

SELECT NAME FROM sys.default_constraints WHERE parent_object_id = OBJECT_ID('dbo.MyTable');

sp_help MyTable

sp_helpconstraint MyTable

All of these produce syntax errors in MariaDB, since they all seem to be for MSSQL or MySQL.

So, what do I need to do to find out the constraint name?

scriptor6
  • 196
  • 3
  • 12
  • Please check the link for the information schemas - system tables that has details of the tables. [schema tables](https://mariadb.com/kb/en/information-schema-tables/). I see tables like CONSTRAINT, CHECK_CONSTRAINTS and REFERENTIAL_CONSTRAINTS. Search in there. – Praveen Apr 11 '21 at 19:02
  • [Alter Table - default value](https://mariadb.com/kb/en/altering-tables-in-mariadb/) This page has the sql to change the default value. See if that helps. – Praveen Apr 11 '21 at 19:04
  • @praveen thanks, that is exactly what I needed to do! I'm not really sure how I didn't end up finding that. – scriptor6 Apr 11 '21 at 20:57

1 Answers1

0

Constraints are shown in the output of SHOW CREATE TABLE <table-name> along with everything else that relates to a table.

markusjm
  • 2,358
  • 1
  • 11
  • 23