[英]changing null to not null in postgresql via c#
我有一個PostgreSql DB連接到Visual Studio。 我想通過Visual Studio將一列(我想要的列)從null更改為not null。 我該怎么做? 在互聯網上找不到此內容。
試試這個代碼:
SqlConnection sqlConnection1 = new SqlConnection("Your Connection String");
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandText = "ALTER TABLE YourTableName ALTER COLUMN YourColumnName DROP NOT NULL;";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
reader = cmd.ExecuteReader();
// Data is accessible through the DataReader object here.
sqlConnection1.Close();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.