更新資料庫使用者

本範例說明如何更新現有資料庫使用者的屬性。您可以透過這個方法變更使用者密碼,或在欄位遮罩中指定要更新的欄位,藉此修改使用者獲派的資料庫角色。

程式碼範例

C#

如要向 AlloyDB 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證機制」。

using Google.Cloud.AlloyDb.V1;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedAlloyDBAdminClientSnippets
{
    /// <summary>Snippet for UpdateUser</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void UpdateUser()
    {
        // Create client
        AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.Create();
        // Initialize request argument(s)
        User user = new User();
        FieldMask updateMask = new FieldMask();
        // Make the request
        User response = alloyDBAdminClient.UpdateUser(user, updateMask);
    }
}

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽工具。