开发者

MySQL syntax: can't create table

开发者 https://www.devze.com 2022-12-27 19:47 出处:网络
mysql> create table balance_sheet( -> Cash_and_cash_equivalentsVARCHAR(20), -> Trading_financial_assetsVARCHAR(20),
mysql> create table balance_sheet(
    -> Cash_and_cash_equivalents  VARCHAR(20),
    -> Trading_financial_assets  VARCHAR(20),
    -> Note_receivable  VARCHAR(20),
    -> Account_receivable  VARCHAR(20),
    -> Advance_money  VARCHAR(20),
    -> Interest_receivable  VARCHAR(20),
    -> Dividend_receivable  VARCHAR(20),
    -> Other_notes_receivable  VARCHAR(20),
    -> Due_from_related_parties  VARCHAR(20),
    -> Inventory  VARCHAR(20),
    -> Consumptive_biological_assets  VARCHAR(20),
    -> Non_current_asset(expire_in_a_year)  VARCHAR(20),
    -> Other_current_assets  VARCHAR(20),
    -> Total_current_assets  VARCHAR(20),
    -> Available_for_sale_financial_assets  VARCHAR(20),
    -> Held_to_maturity_investment  VARCHAR(20),
    -> Long_term_account_receivable  VARCHAR(20),
    -> Long_term_equity_investment  VARCHAR(20),
    -> Investment_real_eastate  VARCHAR(20),
    -> Fixed_assets  VARCHAR(20),
    -> Construction_in_progress  VARCHAR(20),
    -> Project_material  VARCHAR(20),
    -> Liquidation_of_fixed_assets  VARCHAR(20),
    -> Capitalized_biological_assets  VARCHAR(20),
    -> Oil_and_gas_assets  VARCHAR(20),
    -> Intangible_assets  VARCHAR(20),
    -> R&d_expense  VARCHAR(20),
    -> Goodwill  VARCHAR(20),
    -> Deferred_assets  VARCHAR(20),
    -> Deferred_income_tax_assets  VARCHAR(20),
    -> Other_non_current_assets  VARCHAR(20),
    -> Total_non_current_assets  VARCHAR(20),
    -> Total_assets  VARCHAR(20),
    -> Short_term_borrowing  VARCHAR(20),
    -> Transaction_financial_liabilities  VARCHAR(20),
    -> Notes_payable  VARCHAR(20),
    -> Account_payable  VARCHAR(20),
    -> Item_received_in_advance  VARCHAR(20),
    -> Employee_pay_payable  VARCHAR(20),
    -> Tax_payable  VARCHAR(20),
    -> Interest_payable  VARCHAR(20),
    -> Dividend_payable  VARCHAR(20),
    -> Other_account_payable  VARCHAR(20),
    -> Due_to_related_parties  VARCHAR(20),
    -> Non_current_liabilities_due_within_one_year  VARCHAR(20),
    -> Other_current_liabilities  VARCHAR(20),
    -> Total_current_liabilities  VARCHAR(20),
    -> Long_term_loan  VARCHAR(20),
    -> Bonds_payable  VARCHAR(20),
    -> Long_term_payable  VARCHAR(20),
    -> Specific_payable  VARCHAR(20),
    -> Estimated_liabilities  VARCHAR(20),
    -> Deferred_income_tax_liabilities  VARCHAR(20),
    -> Other_non_current_liabilities  VARCHAR(20),
    -> Total_non_current_liabilities  VARCHAR(20),
    -> Total_liabilities  VARCHAR(20),
    -> Paid_in_capital  VARCHAR(20),
    -> Contributed_surplus  VARCHAR(20),
    -> Treasury_stock  VARCHAR(20),
    -> Earned_surplus  VARCHAR(20),
    -> Retained_earnings  VARCHAR(20),
    -> Tr开发者_StackOverflowanslation_reserve  VARCHAR(20),
    -> Nonrecurring_items  VARCHAR(20),
    -> Total_equity(non)  VARCHAR(20),
    -> Minority_interests  VARCHAR(20),
    -> Total_equity  VARCHAR(20),
    -> Total_liabilities_&_shareholder's_equity  VARCHAR(20));
    '>
    '> 

when i press enter,there is the output of '> ,no other reaction ,what's wrong?


Your problem is in the last line. Column names cannot contain & or ':

-> Total_liabilities_&_shareholder's_equity VARCHAR(20));

Change it to:

-> Total_liabilities_shareholders_equity VARCHAR(20));

Edit

It turns out that MySQL does support special characters in column names, but you must escape them:

-> `Total_liabilities_&_shareholder's_equity` VARCHAR(20));

I highly recommend against doing this though for readability reasons.

From the docs:

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. The set of alphanumeric characters from the current character set, “_”, and “$” are not special.

The identifier quote character is the backtick (“`”).


use only alphanumeric characters in the field names. no & and ' characters


The SO code highlighting is a hint. You have an apostrophe in one of your field names, which MySQL is interpreting as the beginning of a string literal which is never terminated. It is patiently waiting for you to finish your string.

0

精彩评论

暂无评论...
验证码 换一张
取 消