MySQL: DEFAULT constraint is easy

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 19

  • @BroCodez
    @BroCodez  2 роки тому +8

    - EXAMPLE 1
    CREATE TABLE products (
    product_id INT,
    product_name varchar(25),
    price DECIMAL(4, 2) DEFAULT 0
    );
    ALTER TABLE products
    ALTER price SET DEFAULT 0;
    INSERT INTO products (product_id, product_name)
    VALUES (104, "straw"),
    (105, "napkin"),
    (106, "fork"),
    (107, "spoon");
    SELECT * FROM products;
    - EXAMPLE 2
    CREATE TABLE transactions(
    transaction_id INT,
    amount DECIMAL(5, 2),
    transaction_date DATETIME DEFAULT NOW()
    );
    SELECT * FROM transactions;
    INSERT INTO transactions (transaction_id, amount)
    VALUES (1, 4.99);
    SELECT * FROM transactions;
    INSERT INTO transactions (transaction_id, amount)
    VALUES (2, 2.89);
    SELECT * FROM transactions;
    INSERT INTO transactions (transaction_id, amount)
    VALUES (3, 8.37);
    SELECT * FROM transactions;
    DROP TABLE transactions;

  • @vaishnutejass2724
    @vaishnutejass2724 2 роки тому +4

    very easy to understand thanku

  • @bichoron3603
    @bichoron3603 5 місяців тому

    Great!!
    Please keep uploading videos of sql more & more

  • @timon1816
    @timon1816 2 роки тому

    Dude, I was just thinking about trying Mysql today and you're releasing this video. Thank you very much!

  • @AishaSalat-k8i
    @AishaSalat-k8i 2 місяці тому

    i just see myself graduating because of your page bro,thank you so much

  • @GldnClaw
    @GldnClaw 9 місяців тому +1

    2:24 looks like you answered my question from a few videos ago.

  • @mitishacolbert277
    @mitishacolbert277 3 місяці тому

    You are the best

  • @bartsworkshop
    @bartsworkshop Рік тому

    Thank you for making these videos, they are easy to follow and understand.

  • @sweethomes674
    @sweethomes674 2 роки тому +1

    Thank you-excellent 🕊

  • @imanelmzk2064
    @imanelmzk2064 8 місяців тому

    you're a Legend, thank you so much!!, that's so helpful!!!!

  • @mohaymenul-islam
    @mohaymenul-islam Місяць тому

  • @MISA-qy4hx
    @MISA-qy4hx Рік тому +4

    Why did you use ALTER instead of MODIFY? 03:40

    • @dixsonjoy5394
      @dixsonjoy5394 10 місяців тому

      I also have this doubt

    • @apoorvsxna
      @apoorvsxna 4 місяці тому +1

      This would also work-
      ALTER TABLE products
      MODIFY price DECIMAL (5,2) DEFAULT 0.00;

  • @omarhashem6358
    @omarhashem6358 2 роки тому

    Please continue the series❤

  • @techboomers8935
    @techboomers8935 2 роки тому

    Kindly kindly Bro share us your Programming life journey or Q/A OR you interview and face revealed, love from Pakistan

  • @Crazy_moments_of_footbal-qz1qr
    @Crazy_moments_of_footbal-qz1qr 8 місяців тому

    you great!!!!!!

  • @nirajchaudhary1621
    @nirajchaudhary1621 2 місяці тому

    👀